Re: [PATCH spice-server] red-worker: Set thread name if possible

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Aug 31, 2017 at 02:45:45PM +0100, Frediano Ziglio wrote:
> Name will be visible in debugger and /proc filesystem
> 
> Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
> ---
>  configure.ac        | 5 +++++
>  server/red-worker.c | 7 +++++++
>  2 files changed, 12 insertions(+)
> 
> diff --git a/configure.ac b/configure.ac
> index f80193b3..874846bb 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -57,6 +57,11 @@ AS_IF([test "x$have_tcp_keepidle" = "xyes"],
>  )
>  AC_FUNC_ALLOCA
>  
> +save_LDFLAGS="$LIBS"
> +LDFLAGS="$LDFLAGS -pthread"
> +AC_CHECK_FUNCS([pthread_setname_np])
> +LDFLAGS="$save_LDFLAGS"

This was added more than 7 years ago in glibc 2.12, not sure we need an
explicit test for it? glib2 has autoconf checks for pthread_setname_np,
but it's because the interface is different on OSX than on Linux.


> +
>  SPICE_LT_VERSION=m4_format("%d:%d:%d", SPICE_CURRENT, SPICE_REVISION, SPICE_AGE)
>  AC_SUBST(SPICE_LT_VERSION)
>  
> diff --git a/server/red-worker.c b/server/red-worker.c
> index 81a318ca..5a91e7a6 100644
> --- a/server/red-worker.c
> +++ b/server/red-worker.c
> @@ -19,6 +19,10 @@
>  #include <config.h>
>  #endif
>  
> +#ifdef HAVE_PTHREAD_SETNAME_NP
> +#define _GNU_SOURCE
> +#endif
> +
>  #include <stdio.h>
>  #include <stdarg.h>
>  #include <stdlib.h>
> @@ -1410,6 +1414,9 @@ bool red_worker_run(RedWorker *worker)
>          spice_error("create thread failed %d", r);
>      }
>      pthread_sigmask(SIG_SETMASK, &curr_sig_mask, NULL);
> +#ifdef HAVE_PTHREAD_SETNAME_NP
> +    pthread_setname_np(worker->thread, "SPICE Worker");

"SPICE QXL/Cursor Worker Thread"? Or too long?

> +#endif
>  
Apart from these comments (which you can feel free to ignore),

Acked-by: Christophe Fergeau <cfergeau@xxxxxxxxxx>

Christophe
>      return r == 0;
>  }
> -- 
> 2.13.5
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel@xxxxxxxxxxxxxxxxxxxxx
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]