From owner-svn-src-all@FreeBSD.ORG Fri Sep 24 07:52:07 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9454A106566C; Fri, 24 Sep 2010 07:52:07 +0000 (UTC) (envelope-from davidxu@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 69E9C8FC1C; Fri, 24 Sep 2010 07:52:07 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o8O7q7MI094106; Fri, 24 Sep 2010 07:52:07 GMT (envelope-from davidxu@svn.freebsd.org) Received: (from davidxu@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o8O7q7Zh094102; Fri, 24 Sep 2010 07:52:07 GMT (envelope-from davidxu@svn.freebsd.org) Message-Id: <201009240752.o8O7q7Zh094102@svn.freebsd.org> From: David Xu Date: Fri, 24 Sep 2010 07:52:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r213096 - head/lib/libthr/thread X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Sep 2010 07:52:07 -0000 Author: davidxu Date: Fri Sep 24 07:52:07 2010 New Revision: 213096 URL: http://svn.freebsd.org/changeset/base/213096 Log: In most cases, cancel_point and cancel_async needn't be checked again, because cancellation is almostly checked at cancellation points. Modified: head/lib/libthr/thread/thr_cancel.c head/lib/libthr/thread/thr_fork.c head/lib/libthr/thread/thr_private.h Modified: head/lib/libthr/thread/thr_cancel.c ============================================================================== --- head/lib/libthr/thread/thr_cancel.c Fri Sep 24 07:29:29 2010 (r213095) +++ head/lib/libthr/thread/thr_cancel.c Fri Sep 24 07:52:07 2010 (r213096) @@ -131,9 +131,7 @@ _pthread_testcancel(void) { struct pthread *curthread = _get_curthread(); - curthread->cancel_point = 1; testcancel(curthread); - curthread->cancel_point = 0; } void @@ -159,7 +157,7 @@ _thr_cancel_enter2(struct pthread *curth void _thr_cancel_leave(struct pthread *curthread, int maycancel) { + curthread->cancel_point = 0; if (maycancel) testcancel(curthread); - curthread->cancel_point = 0; } Modified: head/lib/libthr/thread/thr_fork.c ============================================================================== --- head/lib/libthr/thread/thr_fork.c Fri Sep 24 07:29:29 2010 (r213095) +++ head/lib/libthr/thread/thr_fork.c Fri Sep 24 07:52:07 2010 (r213096) @@ -248,7 +248,8 @@ _fork(void) _thr_rwlock_unlock(&_thr_atfork_lock); curthread->no_cancel = cancelsave; /* test async cancel */ - _thr_testcancel(curthread); + if (curthread->cancel_async) + _thr_testcancel(curthread); } errno = errsave; Modified: head/lib/libthr/thread/thr_private.h ============================================================================== --- head/lib/libthr/thread/thr_private.h Fri Sep 24 07:29:29 2010 (r213095) +++ head/lib/libthr/thread/thr_private.h Fri Sep 24 07:52:07 2010 (r213096) @@ -357,7 +357,6 @@ struct pthread { #define SHOULD_CANCEL(thr) \ ((thr)->cancel_pending && (thr)->cancel_enable && \ - ((thr)->cancel_point || (thr)->cancel_async) && \ (thr)->no_cancel == 0) /* Cancellation is enabled */