Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 28 Aug 2010 11:43:55 +0300
From:      Kostik Belousov <kostikbel@gmail.com>
To:        Pawel Jakub Dawidek <pjd@FreeBSD.org>
Cc:        svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org
Subject:   Re: svn commit: r211896 - head/sbin/hastd
Message-ID:  <20100828084355.GH2396@deviant.kiev.zoral.com.ua>
In-Reply-To: <20100827215402.GB2077@garage.freebsd.pl>
References:  <201008272049.o7RKn63o007138@svn.freebsd.org> <20100827213827.GD2396@deviant.kiev.zoral.com.ua> <20100827215402.GB2077@garage.freebsd.pl>

next in thread | previous in thread | raw e-mail | index | archive | help

--y3SX8pAkUMTjg65a
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

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 aft=
er
> > the check is done but before the sleep, you loose.
>=20
> 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.
>=20
> > After looking at the signal handler, I noted that you call not async-sa=
fe
> > 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.
>=20
> Which aren't async-safe? pthread stuff?

Yes. All pthread_* namespace is not async-signal safe.

--y3SX8pAkUMTjg65a
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (FreeBSD)

iEYEARECAAYFAkx4zEsACgkQC3+MBN1Mb4jViACg3CXV6cQ8RlDfZP69PRseydkR
lDUAn2dc13lxrLoKqBuCGGevRLokdKGC
=3Pgt
-----END PGP SIGNATURE-----

--y3SX8pAkUMTjg65a--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100828084355.GH2396>