Correct a potential performance problem identified by Nate Clark due to Tomcat Native providing OpenSSL with thread identifiers poorly suited to the hash function used by OpenSSL when selecting a bucket for the hash that holds the per thread error data.
Tomcat Native on Windows was not affected.
This fix applies to OSX and Linux.
Other platforms may still be affected.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/native/trunk@1750514 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/native/src/ssl.c b/native/src/ssl.c
index 99762c7..d9fd657 100644
--- a/native/src/ssl.c
+++ b/native/src/ssl.c
@@ -20,6 +20,10 @@
 #include "apr_atomic.h"
 #include "apr_poll.h"
 
+#ifdef __linux__
+#include <sys/syscall.h>
+#endif
+
 #ifdef HAVE_OPENSSL
 #include "ssl_private.h"
 
@@ -420,6 +424,12 @@
     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(__linux__)
+    return (unsigned long)syscall(SYS_gettid);
 #else
     return (unsigned long)(apr_os_thread_current());
 #endif
diff --git a/xdocs/miscellaneous/changelog.xml b/xdocs/miscellaneous/changelog.xml
index 50fcea6..db335a7 100644
--- a/xdocs/miscellaneous/changelog.xml
+++ b/xdocs/miscellaneous/changelog.xml
@@ -44,6 +44,14 @@
       Correctly handle OS level EAGAIN return codes during non-blocking TLS I/O.
       (markt)
     </fix>
+    <fix>
+      Correct a potential performance problem identified by Nate Clark due to
+      Tomcat Native providing OpenSSL with thread identifiers poorly suited to
+      the hash function used by OpenSSL when selecting a bucket for the hash
+      that holds the per thread error data. Tomcat Native on Windows was not
+      affected. A fix has been applied for OSX and Linux. Other platforms may
+      still be affected. (markt/rjung)
+    </fix>
   </changelog>
 </section>
 <section name="Changes in 1.2.7">