diff options
author | wtc%netscape.com <devnull@localhost> | 1999-02-26 18:34:31 +0000 |
---|---|---|
committer | wtc%netscape.com <devnull@localhost> | 1999-02-26 18:34:31 +0000 |
commit | 9317c58c6ba311b810a4d1f5ac43ada8f62a9303 (patch) | |
tree | ed7ad0081c6fba976686a3c7dcbc58054cc3fb33 | |
parent | 9a47a24402560d9aaa78ee9330f8830f684bb787 (diff) | |
download | nspr-hg-9317c58c6ba311b810a4d1f5ac43ada8f62a9303.tar.gz |
print thread scope.
-rw-r--r-- | pr/tests/io_timeout.c | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/pr/tests/io_timeout.c b/pr/tests/io_timeout.c index 6a0366f2..6e0b8dec 100644 --- a/pr/tests/io_timeout.c +++ b/pr/tests/io_timeout.c @@ -59,6 +59,10 @@ typedef struct threadInfo { PRIntn failed_already = 0; PRIntn debug_mode = 0; +#define LOCAL_SCOPE_STRING "LOCAL scope" +#define GLOBAL_SCOPE_STRING "GLOBAL scope" +#define GLOBAL_BOUND_SCOPE_STRING "GLOBAL_BOUND scope" + void thread_main(void *_info) { @@ -68,9 +72,29 @@ thread_main(void *_info) PRFileDesc *listenSock = NULL; PRFileDesc *clientSock; PRStatus rv; + PRThreadScope tscope; + char *scope_str; + if (debug_mode) printf("thread %d is alive\n", info->id); + tscope = PR_GetThreadScope(PR_GetCurrentThread()); + + switch(tscope) { + case PR_LOCAL_THREAD: + scope_str = LOCAL_SCOPE_STRING; + break; + case PR_GLOBAL_THREAD: + scope_str = GLOBAL_SCOPE_STRING; + break; + case PR_GLOBAL_BOUND_THREAD: + scope_str = GLOBAL_BOUND_SCOPE_STRING; + break; + default: + PR_ASSERT(!"Invalid thread scope"); + break; + } + printf("thread id %d, scope %s\n", info->id, scope_str); listenSock = PR_NewTCPSocket(); if (!listenSock) { @@ -172,6 +196,10 @@ thread_test(PRThreadScope scope, PRInt32 num_threads) 0); if (!thr) { + printf("Failed to create thread, error = %d(%d)\n", + PR_GetError(), PR_GetOSError()); + failed_already=1; + PR_Lock(dead_lock); alive--; PR_Unlock(dead_lock); @@ -229,15 +257,15 @@ int main(int argc, char **argv) debug_mode = 1; #endif + printf("test with global bound thread\n"); + thread_test(PR_GLOBAL_BOUND_THREAD, num_threads); + printf("test with local thread\n"); thread_test(PR_LOCAL_THREAD, num_threads); printf("test with global thread\n"); thread_test(PR_GLOBAL_THREAD, num_threads); - printf("test with global bound thread\n"); - thread_test(PR_GLOBAL_BOUND_THREAD, num_threads); - PR_Cleanup(); if (failed_already) |