hadoop-common-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kiran Kumar M R (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HADOOP-11638) OpensslSecureRandom.c pthreads_thread_id should support FreeBSD and Solaris in addition to Linux
Date Wed, 11 Mar 2015 16:30:40 GMT

    [ https://issues.apache.org/jira/browse/HADOOP-11638?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14357133#comment-14357133

Kiran Kumar M R commented on HADOOP-11638:

I have added new patch-004 to include Mac OS specific code.
Mac has {{int pthread_threadid_np(pthread_t thread, uint64_t *thread_id)}} method to get thread
- Its declared in {{pthread.h}} Refer https://opensource.apple.com/source/libpthread/libpthread-105.1.4/pthread/pthread.h
- Its implementation can be seen at https://opensource.apple.com/source/libpthread/libpthread-105.1.4/src/pthread.c
- Its usage can be seen at https://opensource.apple.com/source/libpthread/libpthread-105.1.4/src/pthread_rwlock.c
as below
  uint64_t myid;
  (void)pthread_threadid_np(pthread_self(), &myid);

Now my patch code is:
static unsigned long pthreads_thread_id(void)
  unsigned long thread_id = 0;
#if defined(__linux__)
  thread_id = (unsigned long)syscall(SYS_gettid);
#elif defined(__FreeBSD__)
  thread_id = (unsigned long)pthread_getthreadid_np();
#elif defined(__sun)
  thread_id = (unsigned long)pthread_self();
#elif defined(__APPLE__ )
  (void)pthread_threadid_np(pthread_self(), &thread_id);
#error "Platform not supported"
  return thread_id;

[~cnauroth], please check if patch-004 works on Mac

> OpensslSecureRandom.c pthreads_thread_id should support FreeBSD and Solaris in addition
to Linux
> ------------------------------------------------------------------------------------------------
>                 Key: HADOOP-11638
>                 URL: https://issues.apache.org/jira/browse/HADOOP-11638
>             Project: Hadoop Common
>          Issue Type: Bug
>          Components: native
>    Affects Versions: 2.6.0
>            Reporter: Dmitry Sivachenko
>            Assignee: Kiran Kumar M R
>              Labels: freebsd
>         Attachments: HADOOP-11638-001.patch, HADOOP-11638-002.patch, HADOOP-11638-003.patch,
> In OpensslSecureRandom.c you use Linux-specific syscall gettid():
> static unsigned long pthreads_thread_id(void)
> {
> return (unsigned long)syscall(SYS_gettid);
> }
> Man page says:
> gettid()  is Linux-specific and should not be used in programs that are
> intended to be portable.
> This breaks hadoop-2.6.0 compilation on FreeBSD (may be on other OSes too).

This message was sent by Atlassian JIRA

View raw message