* [LTP] [PATCH]testfrmw:disable thread cancelability while output is running
@ 2012-03-21 10:23 lidan
2012-03-21 12:28 ` Wanlong Gao
2012-03-22 3:57 ` Wanlong Gao
0 siblings, 2 replies; 3+ messages in thread
From: lidan @ 2012-03-21 10:23 UTC (permalink / raw)
To: ltp-list
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.
Signed-off-by: LIDAN<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..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 <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)
--
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [LTP] [PATCH]testfrmw:disable thread cancelability while output is running
2012-03-21 10:23 [LTP] [PATCH]testfrmw:disable thread cancelability while output is running lidan
@ 2012-03-21 12:28 ` Wanlong Gao
2012-03-22 3:57 ` Wanlong Gao
1 sibling, 0 replies; 3+ messages in thread
From: Wanlong Gao @ 2012-03-21 12:28 UTC (permalink / raw)
To: lidan; +Cc: ltp-list
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<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..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 <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)
> --
> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [LTP] [PATCH]testfrmw:disable thread cancelability while output is running
2012-03-21 10:23 [LTP] [PATCH]testfrmw:disable thread cancelability while output is running lidan
2012-03-21 12:28 ` Wanlong Gao
@ 2012-03-22 3:57 ` Wanlong Gao
1 sibling, 0 replies; 3+ messages in thread
From: Wanlong Gao @ 2012-03-22 3:57 UTC (permalink / raw)
To: lidan; +Cc: ltp-list
如果用git-sendemail发patch的话可以配置git,更方便。
#cat ~/.gitconfig
1 [user]
2 email = gaowanlong@cn.fujitsu.com
3 name = Wanlong Gao
4 [sendemail]
5 from = Wanlong Gao <gaowanlong@cn.fujitsu.com>
6 smtpuser = gaowanlong@cn.fujitsu.com
7 smtppass = XXXXXXXXXXX
8 smtpserver = smtp.fnst.cn.fujitsu.com
9 smtpencryption = plain
10 [color]
11 diff = true
12 [format]
13 headers = "From: Wanlong Gao <gaowanlong@cn.fujitsu.com>\n"
14 numbered = auto
15 signoff = true
Thanks,
Wanlong Gao
> 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.
>
>
> Signed-off-by: LIDAN<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..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 <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)
> --
> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-03-22 3:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-21 10:23 [LTP] [PATCH]testfrmw:disable thread cancelability while output is running lidan
2012-03-21 12:28 ` Wanlong Gao
2012-03-22 3:57 ` Wanlong Gao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox