[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-ha-dev
Subject:    Re: [Linux-ha-dev] Patch for bug 499
From:       Alan Robertson <alanr () unix ! sh>
Date:       2005-05-24 5:09:57
Message-ID: 4292B725.1050600 () unix ! sh
[Download RAW message or body]

Guochun Shi wrote:
> At 09:21 AM 5/21/2005 -0600, you wrote:
> 
> > I wrote a workaround for bug 499 - but since this rarely happens to me, I don't \
> > know for sure if this patch will help. 
> > On the other hand, it looks good to me :-).
> > 
> > I have not applied this patch to CVS yet.
> > 
> > -- 
> > Alan Robertson <alanr@unix.sh>
> > 
> > "Openness is the foundation and preservative of friendship...  Let me claim from \
> > you at all times your undisguised opinions." - William Wilberforce 
> > 
> > Index: GSource.c
> > ===================================================================
> > RCS file: /home/cvs/linux-ha/linux-ha/lib/clplumbing/GSource.c,v
> > retrieving revision 1.40
> > diff -u -r1.40 GSource.c
> > --- GSource.c   18 May 2005 17:38:30 -0000      1.40
> > +++ GSource.c   21 May 2005 14:51:19 -0000
> > @@ -12,6 +12,7 @@
> > #include <clplumbing/cl_signal.h>
> > #include <clplumbing/GSource.h>
> > #include <clplumbing/proctrack.h>
> > +#include <clplumbing/timers.h>
> > 
> > #define        MAG_GFDSOURCE   0xfeed0001U
> > #define        MAG_GCHSOURCE   0xfeed0002U
> > @@ -929,23 +930,59 @@
> > * Functions to handle child process
> > */
> > 
> > +#define        WAITALARM       5000L /* milliseconds */
> > +
> > +static int     alarm_count = 0;
> > +static void
> > +G_main_alarm_helper(int nsig)
> > +{
> > +       ++alarm_count;
> > +}
> > 
> > static gboolean
> > child_death_dispatch(int sig, gpointer notused)
> > {
> > -       int status;
> > -       pid_t   pid;
> > -       const int waitflags = WNOHANG;
> > +       int                     status;
> > +       pid_t                   pid;
> > +       const int               waitflags = WNOHANG;
> > +       struct sigaction        saveaction;
> > +       int                     childcount;
> > +
> > +       /*
> > +       * wait3(WNOHANG) isn't _supposed_ to hang
> > +       * Unfortunately, it seems to do just that on some OSes.
> > +       *
> > +       * The workaround is to set an alarm.  I don't think for this purpose
> > +       * that it matters if siginterrupt(SIGALRM) is set TRUE or FALSE since
> > +       * the tiniest little excuse seems to cause the wait3() to finish.
> > +       */
> > 
> > +       memset(&saveaction, 0, sizeof(saveaction));
> > +       cl_signal_set_simple_handler(SIGALRM, G_main_alarm_helper, &saveaction);
> > +
> > +       alarm_count = 0;
> > +       setmsrepeattimer(WAITALARM); /* Might as well be persistent ;-) */
> > while((pid=wait3(&status, waitflags, NULL)) > 0
> > > > errno == EINTR) {
> 
> 
> Will the signal SIGALRM interrupt wait3 system call?
> 
> man siginterrupt:
> 
> The siginterrupt() function changes the restart behaviour when a system
> call is interrupted by the signal sig.  If the flag argument  is  false
> (0),  then  system calls will be restarted if interrupted by the speci-
> fied signal sig.  This is the default  behaviour  in  Linux.   However,
> when a new signal handler is specified with the signal(2) function, the
> system call is interrupted by default.
> 
> If I understand it correctly, SIGALRM's handler is set by sigaction(), not signal() \
> in cl_signal_set_simple_handler(), thus it falls to the default behavior, i.e. the \
> system call will be restarted. IMHO we either need to call siginterrupt(SIGALRM, \
> true), or set the signal handler for SIGALRM using signal()


We set siginterrupt on at this point in time.   Yesterday evening Sun Jiang 
Dong mistakenly removed the code which did this.

BUT there was no evidence at all that we were in the poll code at the time 
this happened.

-- 
     Alan Robertson <alanr@unix.sh>

"Openness is the foundation and preservative of friendship...  Let me claim 
from you at all times your undisguised opinions." - William Wilberforce
_______________________________________________________
Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic