https://bz.apache.org/bugzilla/show_bug.cgi?id=64316
Bug ID: 64316 Summary: Duplicate code for obtaining native current thread id Product: Tomcat Native Version: 1.2.23 Hardware: All OS: All Status: NEW Severity: normal Priority: P2 Component: Library Assignee: dev@tomcat.apache.org Reporter: micha...@apache.org Target Milestone: --- We can improve/reduce code by collapsing those two into one internal function: src/thread.c: > TCN_IMPLEMENT_CALL(jlong, Thread, current)(TCN_STDARGS) > { > UNREFERENCED_STDARGS; > return (jlong)((unsigned long)apr_os_thread_current()); > } and src/ssl.c: > static unsigned long ssl_thread_id(void) > { > /* OpenSSL needs this to return an unsigned long. On OS/390, the pthread > * id is a structure twice that big. Use the TCB pointer instead as a > * unique unsigned long. > */ > #ifdef __MVS__ > struct PSA { > char unmapped[540]; > unsigned long PSATOLD; > } *psaptr = 0; > > return psaptr->PSATOLD; > #elif defined(WIN32) > return (unsigned long)GetCurrentThreadId(); > #elif defined(DARWIN) > uint64_t tid; > pthread_threadid_np(NULL, &tid); > return (unsigned long)tid; > #elif defined(__FreeBSD__) > return (unsigned long)pthread_getthreadid_np(); > #elif defined(__linux__) > return (unsigned long)syscall(SYS_gettid); > #else > return (unsigned long)(apr_os_thread_current()); > #endif > } I think that we can throw away the apr_os_thread_current() because we already have the thread id for Windows and for Unix is it merely: > APR_DECLARE(apr_os_thread_t) apr_os_thread_current(void) > { > return pthread_self(); > } There are implementations for BeOS, Netware and OS/2, but we don't care for them. -- You are receiving this mail because: You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org