You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@trafficserver.apache.org by Igor Galić <i....@brainsware.org> on 2013/05/07 00:31:50 UTC

Re: git commit: TS-1880: add pthread_setname_np support


----- Original Message -----
> Updated Branches:
>   refs/heads/master aeb7442e6 -> 96d979d97
> 
> 
> TS-1880: add pthread_setname_np support
> 
> 
> Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
> Commit:
> http://git-wip-us.apache.org/repos/asf/trafficserver/commit/96d979d9
> Tree:
> http://git-wip-us.apache.org/repos/asf/trafficserver/tree/96d979d9
> Diff:
> http://git-wip-us.apache.org/repos/asf/trafficserver/diff/96d979d9
> 
> Branch: refs/heads/master
> Commit: 96d979d97129c4ba5f7d45d5b323267a4fb62049
> Parents: aeb7442
> Author: James Peach <jp...@apache.org>
> Authored: Fri May 3 19:36:26 2013 -0700
> Committer: James Peach <jp...@apache.org>
> Committed: Mon May 6 12:02:30 2013 -0700
> 
> ----------------------------------------------------------------------
>  CHANGES                                  |    2 +
>  configure.ac                             |   63
>  +++++++++++++++++++++++++
>  iocore/eventsystem/UnixEventProcessor.cc |    4 --
>  lib/ts/ink_thread.h                      |   14 +++++-
>  4 files changed, 77 insertions(+), 6 deletions(-)
> ----------------------------------------------------------------------
> 
> 
> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/96d979d9/CHANGES
> ----------------------------------------------------------------------
> diff --git a/CHANGES b/CHANGES
> index 265eb4f..e932443 100644
> --- a/CHANGES
> +++ b/CHANGES
> @@ -2,6 +2,8 @@
>    Changes with Apache Traffic Server 3.3.3
>  
>  
> +  *) [TS-1880] Use pthread_setname_np to set the thread name on
> multiple platforms.
> +
>    *) [TS-1879] Make the Ptr<> conversion constructor explicit.
>  
>    *) [TS-1768] Prefer AC_SEARCH_LIBS to AC_CHECK_LIB to avoid
>    unnecessary linking.
> 
> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/96d979d9/configure.ac
> ----------------------------------------------------------------------
> diff --git a/configure.ac b/configure.ac
> index c1b2783..fe90f88 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -1342,6 +1342,7 @@ TS_FLAG_HEADERS([sys/epoll.h \
>                    sys/param.h \
>                    sys/pset.h \
>                    sched.h \
> +                  pthread.h \
>                    pthread_np.h \
>                    machine/endian.h \
>                    endian.h \
> @@ -1477,6 +1478,68 @@ TS_FLAG_HEADERS([netinet/ip_icmp.h], [], [],
>  AC_SUBST(netinet_iph)
>  AC_SUBST(netinet_ip_icmph)
>  
> +# Test for additional pthread interfaces.
> +
> +# Darwin pthread_setname_np:
> +AC_MSG_CHECKING([for 1-parameter version of pthread_setname_np()])
> +AC_COMPILE_IFELSE([
> +    AC_LANG_PROGRAM([
> +#if HAVE_PTHREAD_H
> +#include <pthread.h>
> +#endif
> +#if PTHREAD_NP_H
> +#include <pthread_np.h>
> +#endif
> +      ], [
> +        pthread_setname_np("conftest");
> +    ])
> +  ], [
> +    AC_DEFINE(HAVE_PTHREAD_SETNAME_NP_1, 1, [Whether the 1 parameter
> version of pthread_setname_np() is available])
> +    AC_MSG_RESULT([yes])
> +  ], [
> +    AC_MSG_RESULT([no])
> +])
> +
> +# Linux pthread_setname_np:
> +AC_MSG_CHECKING([for 2-parameter version of pthread_setname_np()])
> +AC_COMPILE_IFELSE([
> +    AC_LANG_PROGRAM([
> +#if HAVE_PTHREAD_H
> +#include <pthread.h>
> +#endif
> +#if PTHREAD_NP_H
> +#include <pthread_np.h>
> +#endif
> +      ], [
> +        pthread_setname_np(pthread_self(), "conftest");
> +    ])
> +  ], [
> +    AC_DEFINE(HAVE_PTHREAD_SETNAME_NP_2, 1, [Whether the 2 parameter
> version of pthread_setname_np() is available])
> +    AC_MSG_RESULT([yes])
> +  ], [
> +    AC_MSG_RESULT([no])
> +])
> +
> +# BSD pthread_set_name_np:
> +AC_MSG_CHECKING([for 2-parameter version of pthread_set_name_np()])
> +AC_COMPILE_IFELSE([
> +    AC_LANG_PROGRAM([
> +#if HAVE_PTHREAD_H
> +#include <pthread.h>
> +#endif
> +#if PTHREAD_NP_H
> +#include <pthread_np.h>
> +#endif
> +      ], [
> +        pthread_set_name_np(pthread_self(), "conftest");
> +    ])
> +  ], [
> +    AC_DEFINE(HAVE_PTHREAD_SET_NAME_NP_2, 1, [Whether the 2
> parameter version of pthread_set_name_np() is available])
> +    AC_MSG_RESULT([yes])
> +  ], [
> +    AC_MSG_RESULT([no])
> +])
> +

given this amount of code, we should off-load this to build/pthread.m4

-- i
Igor Galić

Tel: +43 (0) 664 886 22 883
Mail: i.galic@brainsware.org
URL: http://brainsware.org/
GPG: 6880 4155 74BD FD7C B515  2EA5 4B1D 9E08 A097 C9AE


Re: git commit: TS-1880: add pthread_setname_np support

Posted by James Peach <jp...@apache.org>.
On May 6, 2013, at 3:31 PM, Igor Galić <i....@brainsware.org> wrote:

> 
> 
> ----- Original Message -----
>> Updated Branches:
>>  refs/heads/master aeb7442e6 -> 96d979d97
>> 
>> 
>> TS-1880: add pthread_setname_np support
>> 
>> 
>> Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
>> Commit:
>> http://git-wip-us.apache.org/repos/asf/trafficserver/commit/96d979d9
>> Tree:
>> http://git-wip-us.apache.org/repos/asf/trafficserver/tree/96d979d9
>> Diff:
>> http://git-wip-us.apache.org/repos/asf/trafficserver/diff/96d979d9
>> 
>> Branch: refs/heads/master
>> Commit: 96d979d97129c4ba5f7d45d5b323267a4fb62049
>> Parents: aeb7442
>> Author: James Peach <jp...@apache.org>
>> Authored: Fri May 3 19:36:26 2013 -0700
>> Committer: James Peach <jp...@apache.org>
>> Committed: Mon May 6 12:02:30 2013 -0700
>> 
>> ----------------------------------------------------------------------
>> CHANGES                                  |    2 +
>> configure.ac                             |   63
>> +++++++++++++++++++++++++
>> iocore/eventsystem/UnixEventProcessor.cc |    4 --
>> lib/ts/ink_thread.h                      |   14 +++++-
>> 4 files changed, 77 insertions(+), 6 deletions(-)
>> ----------------------------------------------------------------------
>> 
>> 
>> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/96d979d9/CHANGES
>> ----------------------------------------------------------------------
>> diff --git a/CHANGES b/CHANGES
>> index 265eb4f..e932443 100644
>> --- a/CHANGES
>> +++ b/CHANGES
>> @@ -2,6 +2,8 @@
>>   Changes with Apache Traffic Server 3.3.3
>> 
>> 
>> +  *) [TS-1880] Use pthread_setname_np to set the thread name on
>> multiple platforms.
>> +
>>   *) [TS-1879] Make the Ptr<> conversion constructor explicit.
>> 
>>   *) [TS-1768] Prefer AC_SEARCH_LIBS to AC_CHECK_LIB to avoid
>>   unnecessary linking.
>> 
>> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/96d979d9/configure.ac
>> ----------------------------------------------------------------------
>> diff --git a/configure.ac b/configure.ac
>> index c1b2783..fe90f88 100644
>> --- a/configure.ac
>> +++ b/configure.ac
>> @@ -1342,6 +1342,7 @@ TS_FLAG_HEADERS([sys/epoll.h \
>>                   sys/param.h \
>>                   sys/pset.h \
>>                   sched.h \
>> +                  pthread.h \
>>                   pthread_np.h \
>>                   machine/endian.h \
>>                   endian.h \
>> @@ -1477,6 +1478,68 @@ TS_FLAG_HEADERS([netinet/ip_icmp.h], [], [],
>> AC_SUBST(netinet_iph)
>> AC_SUBST(netinet_ip_icmph)
>> 
>> +# Test for additional pthread interfaces.
>> +
>> +# Darwin pthread_setname_np:
>> +AC_MSG_CHECKING([for 1-parameter version of pthread_setname_np()])
>> +AC_COMPILE_IFELSE([
>> +    AC_LANG_PROGRAM([
>> +#if HAVE_PTHREAD_H
>> +#include <pthread.h>
>> +#endif
>> +#if PTHREAD_NP_H
>> +#include <pthread_np.h>
>> +#endif
>> +      ], [
>> +        pthread_setname_np("conftest");
>> +    ])
>> +  ], [
>> +    AC_DEFINE(HAVE_PTHREAD_SETNAME_NP_1, 1, [Whether the 1 parameter
>> version of pthread_setname_np() is available])
>> +    AC_MSG_RESULT([yes])
>> +  ], [
>> +    AC_MSG_RESULT([no])
>> +])
>> +
>> +# Linux pthread_setname_np:
>> +AC_MSG_CHECKING([for 2-parameter version of pthread_setname_np()])
>> +AC_COMPILE_IFELSE([
>> +    AC_LANG_PROGRAM([
>> +#if HAVE_PTHREAD_H
>> +#include <pthread.h>
>> +#endif
>> +#if PTHREAD_NP_H
>> +#include <pthread_np.h>
>> +#endif
>> +      ], [
>> +        pthread_setname_np(pthread_self(), "conftest");
>> +    ])
>> +  ], [
>> +    AC_DEFINE(HAVE_PTHREAD_SETNAME_NP_2, 1, [Whether the 2 parameter
>> version of pthread_setname_np() is available])
>> +    AC_MSG_RESULT([yes])
>> +  ], [
>> +    AC_MSG_RESULT([no])
>> +])
>> +
>> +# BSD pthread_set_name_np:
>> +AC_MSG_CHECKING([for 2-parameter version of pthread_set_name_np()])
>> +AC_COMPILE_IFELSE([
>> +    AC_LANG_PROGRAM([
>> +#if HAVE_PTHREAD_H
>> +#include <pthread.h>
>> +#endif
>> +#if PTHREAD_NP_H
>> +#include <pthread_np.h>
>> +#endif
>> +      ], [
>> +        pthread_set_name_np(pthread_self(), "conftest");
>> +    ])
>> +  ], [
>> +    AC_DEFINE(HAVE_PTHREAD_SET_NAME_NP_2, 1, [Whether the 2
>> parameter version of pthread_set_name_np() is available])
>> +    AC_MSG_RESULT([yes])
>> +  ], [
>> +    AC_MSG_RESULT([no])
>> +])
>> +
> 
> given this amount of code, we should off-load this to build/pthread.m4

Yeh we should probably do this. When I started this patch I didn't realize there would be so much pointless platform divergence

J