diff --git a/glib/gthread-posix.c b/glib/gthread-posix.c index f36055925..f09f58a15 100644 --- a/glib/gthread-posix.c +++ b/glib/gthread-posix.c @@ -1116,11 +1116,12 @@ g_private_replace (GPrivate *key, gint status; old = pthread_getspecific (*impl); - if (old && key->notify) - key->notify (old); if G_UNLIKELY ((status = pthread_setspecific (*impl, value)) != 0) g_thread_abort (status, "pthread_setspecific"); + + if (old && key->notify) + key->notify (old); } /* {{{1 GThread */ diff --git a/glib/gthread-win32.c b/glib/gthread-win32.c index 54f74f2f8..0c37dc6c1 100644 --- a/glib/gthread-win32.c +++ b/glib/gthread-win32.c @@ -373,9 +373,9 @@ g_private_replace (GPrivate *key, gpointer old; old = TlsGetValue (impl); + TlsSetValue (impl, value); if (old && key->notify) key->notify (old); - TlsSetValue (impl, value); } /* {{{1 GThread */