From: Thomas Kristensen Date: Sun, 14 Mar 2010 09:47:17 +0000 (+0200) Subject: Close the socket event in finalizer instead of in close method X-Git-Tag: 2.23.6~32 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1be8ad35144d34de99b6153cbbfa8f9add46888b;p=platform%2Fupstream%2Fglib.git Close the socket event in finalizer instead of in close method There might be a GSource attached to a GMainContext, about to be removed by a pending cancellation. Deleting the handle too early will trigger a g_warning in the "select()" call in GMainContext. Attached patch fixes this by deferring destruction of WSAEVENT object until GSocket's finalize(). Patch from bug #612702. Signed-off-by: Tor Lillqvist --- diff --git a/gio/gsocket.c b/gio/gsocket.c index 398c4d5..91983e4 100644 --- a/gio/gsocket.c +++ b/gio/gsocket.c @@ -614,6 +614,12 @@ g_socket_finalize (GObject *object) g_socket_close (socket, NULL); #ifdef G_OS_WIN32 + if (socket->priv->event != WSA_INVALID_EVENT) + { + WSACloseEvent (socket->priv->event); + socket->priv->event = WSA_INVALID_EVENT; + } + g_assert (socket->priv->requested_conditions == NULL); #endif @@ -2002,14 +2008,6 @@ g_socket_close (GSocket *socket, break; } -#ifdef G_OS_WIN32 - if (socket->priv->event != WSA_INVALID_EVENT) - { - WSACloseEvent (socket->priv->event); - socket->priv->event = WSA_INVALID_EVENT; - } -#endif - socket->priv->connected = FALSE; socket->priv->closed = TRUE;