You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2020/04/06 13:26:08 UTC

[Bug 64316] New: Duplicate code for obtaining native current thread id

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: michaelo@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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 64316] Duplicate code for obtaining native current thread id

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=64316

Michael Osipov <mi...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #1 from Michael Osipov <mi...@apache.org> ---
Fixed in:
- master for 1.2.24 onwards

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org