From owner-freebsd-current@FreeBSD.ORG Wed Aug 4 15:46:21 2010 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DFDC81065672 for ; Wed, 4 Aug 2010 15:46:20 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id 7E0808FC0C for ; Wed, 4 Aug 2010 15:46:20 +0000 (UTC) Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id o74Fk4o5003435 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 4 Aug 2010 18:46:05 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4) with ESMTP id o74Fk4Me068928; Wed, 4 Aug 2010 18:46:04 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4/Submit) id o74Fk4dI068927; Wed, 4 Aug 2010 18:46:04 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Wed, 4 Aug 2010 18:46:04 +0300 From: Kostik Belousov To: Andrew Gallatin Message-ID: <20100804154604.GY22295@deviant.kiev.zoral.com.ua> References: <4C597AE8.5090703@cs.duke.edu> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="eci7kgoNre1oTc2t" Content-Disposition: inline In-Reply-To: <4C597AE8.5090703@cs.duke.edu> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-2.3 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_40, DNS_FROM_OPENWHOIS autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: current@freebsd.org Subject: Re: Incorrect cv_wait_sig() return values? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Aug 2010 15:46:21 -0000 --eci7kgoNre1oTc2t Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Aug 04, 2010 at 10:36:24AM -0400, Andrew Gallatin wrote: > Hi, >=20 > I recently noticed that cv_wait_sig() will return -1 > rather than EINTR when a SIGINT is delivered. This is > in contrast to CONDVAR(9) which states: >=20 > <...> > cv_wait_sig() and cv_timedwait_sig() return prematurely with a > value of EINTR or ERESTART if a signal is caught > <...> >=20 > To demonstrate the problem outside my out-of-tree driver, I > took the skeleton driver from > http://www.captain.at/programming/freebsd/ > and added the following function, invoked at module > load: >=20 > static struct mtx m; > static struct cv c; >=20 > static void > cv_test(void) > { > int rc; >=20 > mtx_init(&m, "skel_m", MTX_DEF, MTX_DEF); > cv_init(&c, "skel_c"); > mtx_lock(&m); > rc =3D cv_wait_sig(&c, &m); > mtx_unlock(&m); > printf("cv_wait_sig returned %d\n", rc); > cv_destroy(&c); > mtx_destroy(&m); > } >=20 >=20 > I load the module, and I ^C kldload after a few seconds > to break out of the cv_wait_sig(), which results in this > output on console: >=20 > Skeleton KLD loaded. > cv_wait_sig returned -1 >=20 > Am I doing something wrong, or are condvars broken? > I've tried to track this down with dtrace, but failed.. What version of the system do you use ? I cannot confirm this on the HEAD from several hours ago with the following test module. On the SIGINT I get `4' printed, which is EINTR. #include #include #include #include #include #include #include static struct mtx m; static struct cv c; static void cv_test(void) { int rc; mtx_init(&m, "skel_m", MTX_DEF, MTX_DEF); cv_init(&c, "skel_c"); mtx_lock(&m); rc =3D cv_wait_sig(&c, &m); mtx_unlock(&m); printf("cv_wait_sig returned %d\n", rc); cv_destroy(&c); mtx_destroy(&m); } static int test_load(module_t mod, int cmd, void *arg) { switch (cmd) { case MOD_LOAD: cv_test(); break; } return (0); } static moduledata_t test_module =3D { "test", &test_load, NULL }; DECLARE_MODULE(test, test_module, SI_SUB_KLD, SI_ORDER_FIRST); MODULE_VERSION(test, 1); --eci7kgoNre1oTc2t Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (FreeBSD) iEYEARECAAYFAkxZizwACgkQC3+MBN1Mb4ikyACgsI1KkPSTDHHUd0frioHhdl+3 esIAn3GHS4Mjla1lJV6daNoqadwgpPps =I/Zp -----END PGP SIGNATURE----- --eci7kgoNre1oTc2t--