All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Tokarev <mjt@tls.msk.ru>
To: qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org, Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-trivial] [PATCH v2 1/7] do not call g_thread_init() for glib >= 2.31
Date: Sat, 03 May 2014 13:11:04 +0400	[thread overview]
Message-ID: <5364B2A8.7050709@msgid.tls.msk.ru> (raw)
In-Reply-To: <1399041361-30496-2-git-send-email-mjt@msgid.tls.msk.ru>

02.05.2014 18:35, Michael Tokarev wrote:
> glib >= 2.31 always enables thread support and g_thread_supported()
> is #defined to 1, there's no need to call g_thread_init() anymore,
> and it definitely does not need to report error which never happens.
> Keep code for old < 2.31 glibc anyway for now, just #ifdef it
> differently.

Applied to -trivial, thanks!

/mjt

> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
> Cc: qemu-trivial@nongnu.org
> ---
>  coroutine-gthread.c |    7 ++-----
>  util/osdep.c        |   21 +++++++++------------
>  2 files changed, 11 insertions(+), 17 deletions(-)
> 
> diff --git a/coroutine-gthread.c b/coroutine-gthread.c
> index d3e5b99..a61efe0 100644
> --- a/coroutine-gthread.c
> +++ b/coroutine-gthread.c
> @@ -115,14 +115,11 @@ static inline GThread *create_thread(GThreadFunc func, gpointer data)
>  
>  static void __attribute__((constructor)) coroutine_init(void)
>  {
> -    if (!g_thread_supported()) {
>  #if !GLIB_CHECK_VERSION(2, 31, 0)
> +    if (!g_thread_supported()) {
>          g_thread_init(NULL);
> -#else
> -        fprintf(stderr, "glib threading failed to initialize.\n");
> -        exit(1);
> -#endif
>      }
> +#endif
>  
>      init_coroutine_cond();
>  }
> diff --git a/util/osdep.c b/util/osdep.c
> index a9029f8..b2bd154 100644
> --- a/util/osdep.c
> +++ b/util/osdep.c
> @@ -436,23 +436,20 @@ int socket_init(void)
>      return 0;
>  }
>  
> -/* Ensure that glib is running in multi-threaded mode */
> +#if !GLIB_CHECK_VERSION(2, 31, 0)
> +/* Ensure that glib is running in multi-threaded mode
> + * Old versions of glib require explicit initialization.  Failure to do
> + * this results in the single-threaded code paths being taken inside
> + * glib.  For example, the g_slice allocator will not be thread-safe
> + * and cause crashes.
> + */
>  static void __attribute__((constructor)) thread_init(void)
>  {
>      if (!g_thread_supported()) {
> -#if !GLIB_CHECK_VERSION(2, 31, 0)
> -        /* Old versions of glib require explicit initialization.  Failure to do
> -         * this results in the single-threaded code paths being taken inside
> -         * glib.  For example, the g_slice allocator will not be thread-safe
> -         * and cause crashes.
> -         */
> -        g_thread_init(NULL);
> -#else
> -        fprintf(stderr, "glib threading failed to initialize.\n");
> -        exit(1);
> -#endif
> +       g_thread_init(NULL);
>      }
>  }
> +#endif
>  
>  #ifndef CONFIG_IOVEC
>  /* helper function for iov_send_recv() */
> 



WARNING: multiple messages have this Message-ID (diff)
From: Michael Tokarev <mjt@tls.msk.ru>
To: qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org, Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [Qemu-trivial] [PATCH v2 1/7] do not call g_thread_init() for glib >= 2.31
Date: Sat, 03 May 2014 13:11:04 +0400	[thread overview]
Message-ID: <5364B2A8.7050709@msgid.tls.msk.ru> (raw)
In-Reply-To: <1399041361-30496-2-git-send-email-mjt@msgid.tls.msk.ru>

02.05.2014 18:35, Michael Tokarev wrote:
> glib >= 2.31 always enables thread support and g_thread_supported()
> is #defined to 1, there's no need to call g_thread_init() anymore,
> and it definitely does not need to report error which never happens.
> Keep code for old < 2.31 glibc anyway for now, just #ifdef it
> differently.

Applied to -trivial, thanks!

/mjt

> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
> Cc: qemu-trivial@nongnu.org
> ---
>  coroutine-gthread.c |    7 ++-----
>  util/osdep.c        |   21 +++++++++------------
>  2 files changed, 11 insertions(+), 17 deletions(-)
> 
> diff --git a/coroutine-gthread.c b/coroutine-gthread.c
> index d3e5b99..a61efe0 100644
> --- a/coroutine-gthread.c
> +++ b/coroutine-gthread.c
> @@ -115,14 +115,11 @@ static inline GThread *create_thread(GThreadFunc func, gpointer data)
>  
>  static void __attribute__((constructor)) coroutine_init(void)
>  {
> -    if (!g_thread_supported()) {
>  #if !GLIB_CHECK_VERSION(2, 31, 0)
> +    if (!g_thread_supported()) {
>          g_thread_init(NULL);
> -#else
> -        fprintf(stderr, "glib threading failed to initialize.\n");
> -        exit(1);
> -#endif
>      }
> +#endif
>  
>      init_coroutine_cond();
>  }
> diff --git a/util/osdep.c b/util/osdep.c
> index a9029f8..b2bd154 100644
> --- a/util/osdep.c
> +++ b/util/osdep.c
> @@ -436,23 +436,20 @@ int socket_init(void)
>      return 0;
>  }
>  
> -/* Ensure that glib is running in multi-threaded mode */
> +#if !GLIB_CHECK_VERSION(2, 31, 0)
> +/* Ensure that glib is running in multi-threaded mode
> + * Old versions of glib require explicit initialization.  Failure to do
> + * this results in the single-threaded code paths being taken inside
> + * glib.  For example, the g_slice allocator will not be thread-safe
> + * and cause crashes.
> + */
>  static void __attribute__((constructor)) thread_init(void)
>  {
>      if (!g_thread_supported()) {
> -#if !GLIB_CHECK_VERSION(2, 31, 0)
> -        /* Old versions of glib require explicit initialization.  Failure to do
> -         * this results in the single-threaded code paths being taken inside
> -         * glib.  For example, the g_slice allocator will not be thread-safe
> -         * and cause crashes.
> -         */
> -        g_thread_init(NULL);
> -#else
> -        fprintf(stderr, "glib threading failed to initialize.\n");
> -        exit(1);
> -#endif
> +       g_thread_init(NULL);
>      }
>  }
> +#endif
>  
>  #ifndef CONFIG_IOVEC
>  /* helper function for iov_send_recv() */
> 

  reply	other threads:[~2014-05-03  9:11 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-02 14:35 [Qemu-devel] [PATCH v2 0/7] glib thread interface and libcacard cleanups Michael Tokarev
2014-05-02 14:35 ` [Qemu-trivial] [PATCH v2 1/7] do not call g_thread_init() for glib >= 2.31 Michael Tokarev
2014-05-02 14:35   ` [Qemu-devel] " Michael Tokarev
2014-05-03  9:11   ` Michael Tokarev [this message]
2014-05-03  9:11     ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
2014-05-02 14:35 ` [Qemu-trivial] [PATCH v2 2/7] glib: move g_poll() replacement into glib-compat.h Michael Tokarev
2014-05-02 14:35   ` [Qemu-devel] " Michael Tokarev
2014-05-03  9:11   ` [Qemu-trivial] " Michael Tokarev
2014-05-03  9:11     ` [Qemu-devel] " Michael Tokarev
2014-05-02 14:35 ` [Qemu-devel] [PATCH v2 3/7] glib-compat.h: add new thread API emulation on top of pre-2.31 API Michael Tokarev
2014-05-02 14:35 ` [Qemu-devel] [PATCH v2 4/7] vscclient: use glib thread primitives not qemu Michael Tokarev
2014-05-02 14:35 ` [Qemu-trivial] [PATCH v2 5/7] libcacard: replace pstrcpy() with memcpy() Michael Tokarev
2014-05-02 14:35   ` [Qemu-devel] " Michael Tokarev
2014-05-02 14:36 ` [Qemu-devel] [PATCH v2 6/7] libcacard: replace qemu thread primitives with glib ones Michael Tokarev
2014-05-02 14:36 ` [Qemu-devel] [PATCH v2 7/7] libcacard: actually use symbols file Michael Tokarev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5364B2A8.7050709@msgid.tls.msk.ru \
    --to=mjt@tls.msk.ru \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.