svn commit: r211896 - head/sbin/hastd

Pawel Jakub Dawidek pjd at FreeBSD.org
Sat Aug 28 08:50:56 UTC 2010


On Sat, Aug 28, 2010 at 11:43:55AM +0300, Kostik Belousov wrote:
> On Fri, Aug 27, 2010 at 11:54:02PM +0200, Pawel Jakub Dawidek wrote:
> > On Sat, Aug 28, 2010 at 12:38:27AM +0300, Kostik Belousov wrote:
> > > > --- head/sbin/hastd/primary.c	Fri Aug 27 20:48:12 2010	(r211895)
> > > > +++ head/sbin/hastd/primary.c	Fri Aug 27 20:49:06 2010	(r211896)
> > > > @@ -1988,7 +1988,9 @@ guard_thread(void *arg)
> > > >  				rw_unlock(&hio_remote_lock[ii]);
> > > >  			}
> > > >  		}
> > > > -		(void)cv_timedwait(&hio_guard_cond, &hio_guard_lock, timeout);
> > > > +		/* Sleep only if a signal wasn't delivered in the meantime. */
> > > > +		if (!sigexit_received && !sighup_received && !sigchld_received)
> > > > +			cv_timedwait(&hio_guard_cond, &hio_guard_lock, timeout);
> > > >  		mtx_unlock(&hio_guard_lock);
> > > >  	}
> > > >  	/* NOTREACHED */
> > > I wanted to say that this is racy, because if a signal is delivered after
> > > the check is done but before the sleep, you loose.
> > 
> > Yes, I know it is racy, but the race isn't critical anymore, as we will
> > eventually wait at most 10 seconds to handle signals.
> > 
> > > After looking at the signal handler, I noted that you call not async-safe
> > > functions in the handler. This is easy way to get undefined behaviour,
> > > i.e. probably crash. And wakeup from the handler would have the same
> > > race as sigXXX_received check.
> > 
> > Which aren't async-safe? pthread stuff?
> 
> Yes. All pthread_* namespace is not async-signal safe.

Ehh, I'm lame. All I need to do is to use cv_timedwait_sig() instead of
cv_timedwait() and I can remove all pthread stuff from the sighandler.

Thanks!

-- 
Pawel Jakub Dawidek                       http://www.wheelsystems.com
pjd at FreeBSD.org                           http://www.FreeBSD.org
FreeBSD committer                         Am I Evil? Yes, I Am!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/svn-src-all/attachments/20100828/36e78b13/attachment.pgp


More information about the svn-src-all mailing list