From: Wanlong Gao <gaowanlong@cn.fujitsu.com>
To: lidan <li.dan@cn.fujitsu.com>
Cc: ltp-list@lists.sourceforge.net
Subject: Re: [LTP] [PATCHv2]testfrmw:disable thread cancelability while output is running
Date: Thu, 22 Mar 2012 21:07:19 +0800 [thread overview]
Message-ID: <4F6B2407.3090604@cn.fujitsu.com> (raw)
In-Reply-To: <4F6AA2EF.9030403@cn.fujitsu.com>
On 03/22/2012 11:56 AM, 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.
pushed, thanks,
Wanlong Gao
>
> Signed-off-by: DAN LI <li.dan@cn.fujitsu.com>
> ---
> .../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..a9cfbef 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 <time.h>
> #include <sys/types.h>
> +#include <pthread.h>
>
> /* 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)
------------------------------------------------------------------------------
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
prev parent reply other threads:[~2012-03-22 13:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-22 3:56 [LTP] [PATCHv2]testfrmw:disable thread cancelability while output is running lidan
2012-03-22 4:08 ` Wanlong Gao
2012-03-22 13:07 ` Wanlong Gao [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4F6B2407.3090604@cn.fujitsu.com \
--to=gaowanlong@cn.fujitsu.com \
--cc=li.dan@cn.fujitsu.com \
--cc=ltp-list@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox