From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from sog-mx-1.v43.ch3.sourceforge.com ([172.29.43.191] helo=mx.sourceforge.net) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1SAKfA-00084I-9l for ltp-list@lists.sourceforge.net; Wed, 21 Mar 2012 12:29:12 +0000 Received: from [222.73.24.84] (helo=song.cn.fujitsu.com) by sog-mx-1.v43.ch3.sourceforge.com with esmtp (Exim 4.76) id 1SAKf4-0006sC-60 for ltp-list@lists.sourceforge.net; Wed, 21 Mar 2012 12:29:12 +0000 Received: from mailserver.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id q2LCSw7f013003 for ; Wed, 21 Mar 2012 20:28:58 +0800 Message-ID: <4F69C951.10101@cn.fujitsu.com> Date: Wed, 21 Mar 2012 20:28:01 +0800 From: Wanlong Gao MIME-Version: 1.0 References: <4F69AC25.5020301@cn.fujitsu.com> In-Reply-To: <4F69AC25.5020301@cn.fujitsu.com> Subject: Re: [LTP] [PATCH]testfrmw:disable thread cancelability while output is running Reply-To: gaowanlong@cn.fujitsu.com List-Id: Linux Test Project General Discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ltp-list-bounces@lists.sourceforge.net To: lidan Cc: ltp-list@lists.sourceforge.net On 03/21/2012 06:23 PM, lidan wrote: > Function output can be canceled by pthread_cancel(), which, > maybe, leads to a deadlock as it calls pthread_mutex_lock(). > That's catched in case "pthread_join/4-1.c". > > So,disable thread cancelability until output finishes. The concept seems OK, but you should follow the coding style and patch format. Thanks, Wanlong Gao > > > Signed-off-by: LIDAN > --- > .../conformance/interfaces/testfrmw/testfrmw.c | 4 ++++ > 1 files changed, 4 insertions(+), 0 deletions(-) > > diff --git > a/testcases/open_posix_testsuite/conformance/interfaces/testfrmw/testfrmw.c > b/testcases/open_posix_testsuite/conformance/interfaces/testfrmw/testfrmw.c > index 034faa9..fb54ee9 100644 > --- > a/testcases/open_posix_testsuite/conformance/interfaces/testfrmw/testfrmw.c > +++ > b/testcases/open_posix_testsuite/conformance/interfaces/testfrmw/testfrmw.c > @@ -28,6 +28,7 @@ > > #include > #include > +#include > > /* We use a mutex to avoid conflicts in traces */ > static pthread_mutex_t m_trace = PTHREAD_MUTEX_INITIALIZER; > @@ -43,7 +44,9 @@ void output(char *string, ...) > char *ts = "[??:??:??]"; > struct tm *now; > time_t nw; > + int oldstate; > > + pthread_setcancelstate(PTHREAD_CANCEL_DISABLE,&oldstate); > pthread_mutex_lock(&m_trace); > nw = time(NULL); > now = localtime(&nw); > @@ -56,6 +59,7 @@ void output(char *string, ...) > vprintf(string, ap); > va_end(ap); > pthread_mutex_unlock(&m_trace); > + pthread_setcancelstate(oldstate,NULL); > } > > void output_fini(void) > -- > 1.7.1 > > > ------------------------------------------------------------------------------ > This SF email is sponsosred by: > Try Windows Azure free for 90 days Click Here > http://p.sf.net/sfu/sfd2d-msazure > _______________________________________________ > Ltp-list mailing list > Ltp-list@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/ltp-list > ------------------------------------------------------------------------------ This SF email is sponsosred by: Try Windows Azure free for 90 days Click Here http://p.sf.net/sfu/sfd2d-msazure _______________________________________________ Ltp-list mailing list Ltp-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ltp-list