[glib] Ref the passed in socket in g_socket_listener_add_socket (#585599)
- From: Alexander Larsson <alexl src gnome org>
- To: svn-commits-list gnome org
- Subject: [glib] Ref the passed in socket in g_socket_listener_add_socket (#585599)
- Date: Mon, 15 Jun 2009 09:43:23 -0400 (EDT)
commit a640695f1609805a0fe745d35c2055a984410bb5
Author: Alexander Larsson <alexl redhat com>
Date: Mon Jun 15 15:42:38 2009 +0200
Ref the passed in socket in g_socket_listener_add_socket (#585599)
gio/gsocketlistener.c | 23 ++++++++++++++++++-----
1 files changed, 18 insertions(+), 5 deletions(-)
---
diff --git a/gio/gsocketlistener.c b/gio/gsocketlistener.c
index 522ed44..d0025f5 100644
--- a/gio/gsocketlistener.c
+++ b/gio/gsocketlistener.c
@@ -234,6 +234,7 @@ g_socket_listener_add_socket (GSocketListener *listener,
return FALSE;
}
+ g_object_ref (socket);
g_ptr_array_add (listener->priv->sockets, socket);
if (source_object)
@@ -301,15 +302,13 @@ g_socket_listener_add_address (GSocketListener *listener,
g_socket_set_listen_backlog (socket, listener->priv->listen_backlog);
if (!g_socket_bind (socket, address, TRUE, error) ||
- !g_socket_listen (socket, error) ||
- !g_socket_listener_add_socket (listener, socket,
- source_object,
- error))
+ !g_socket_listen (socket, error))
{
g_object_unref (socket);
return FALSE;
}
+ local_address = NULL;
if (effective_address)
{
local_address = g_socket_get_local_address (socket, error);
@@ -318,9 +317,23 @@ g_socket_listener_add_address (GSocketListener *listener,
g_object_unref (socket);
return FALSE;
}
- *effective_address = local_address;
}
+ if (!g_socket_listener_add_socket (listener, socket,
+ source_object,
+ error))
+ {
+ if (local_address)
+ g_object_unref (local_address);
+ g_object_unref (socket);
+ return FALSE;
+ }
+
+ if (effective_address)
+ *effective_address = local_address;
+
+ g_object_unref (socket); /* add_socket refs this */
+
if (G_SOCKET_LISTENER_GET_CLASS (listener)->changed)
G_SOCKET_LISTENER_GET_CLASS (listener)->changed (listener);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]