From owner-freebsd-threads@FreeBSD.ORG Mon Aug 16 08:20:27 2010 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 44A1110656A4; Mon, 16 Aug 2010 08:20:27 +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 B14868FC1F; Mon, 16 Aug 2010 08:20:26 +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 o7G8KMZm056677 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 16 Aug 2010 11:20:22 +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 o7G8KMgM025674; Mon, 16 Aug 2010 11:20:22 +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 o7G8KMlE025673; Mon, 16 Aug 2010 11:20:22 +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: Mon, 16 Aug 2010 11:20:22 +0300 From: Kostik Belousov To: David Xu Message-ID: <20100816082022.GO2396@deviant.kiev.zoral.com.ua> References: <4C63D42D.8040606@freebsd.org> <20100812083006.GR2396@deviant.kiev.zoral.com.ua> <4C642E9B.8000300@freebsd.org> <20100812093353.GS2396@deviant.kiev.zoral.com.ua> <4C650D0F.9060905@freebsd.org> <4C650F27.1000305@freebsd.org> <20100813141402.GW2396@deviant.kiev.zoral.com.ua> <4C65E0FE.2030803@freebsd.org> <20100814144715.GB2396@deviant.kiev.zoral.com.ua> <4C6926D0.2020909@freebsd.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="dDdTYOCAbkFo0FQC" Content-Disposition: inline In-Reply-To: <4C6926D0.2020909@freebsd.org> 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=-3.5 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00, 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: freebsd-threads@freebsd.org Subject: Re: PTHREAD_CANCEL_DEFERRED X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Aug 2010 08:20:27 -0000 --dDdTYOCAbkFo0FQC Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Aug 16, 2010 at 11:53:52AM +0000, David Xu wrote: > Kostik Belousov wrote: >=20 > >Missed this, thank you for pointing it out. Updated patch is at > >http://people.freebsd.org/~kib//misc/cancel_defer.2.patch >=20 > I found SIGCANCEL is masked by > thr_cancel_deferred(THR_CANCEL_DEFERRED_ENABLE), issignal() does not > return the masked signal, so how a cancellation point syscall can be > interrupted by SIGCANCEL ? I think if a thread being canceled calls > msleep(PCATCH), it should find the signal and return EINTR. >=20 Yes, for EINTR and ERESTART case, the thread should be canceled. Please look at the check_cancel() helper that is called at the syscall entry and before return. If the check_cancel() decided that the syscall is cancellation point and the thread in the deferred cancel mode, and EINTR or ERESTART is supplied as error code, then SIGCANCEL is removed from the thread signal mask. It is restored in the mask by ast(). --dDdTYOCAbkFo0FQC Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (FreeBSD) iEYEARECAAYFAkxo9MYACgkQC3+MBN1Mb4jAWQCdEG8Xj3rfSPgmIi1j3sDDpW5R Fq8AoPY7vH6ph1gGyZHMkVey7BePOFLe =hWdZ -----END PGP SIGNATURE----- --dDdTYOCAbkFo0FQC--