mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-12 15:36:17 +01:00
GDBusServer: Avoid handling incoming connections after stop() has been called
Without this fix, we'd sometimes run code after stop() and finalize() to handle incoming requests. This was observed in the gdbus-peer test case occasionally crashing: $ ./gdbus-peer /gdbus/peer-to-peer: OK /gdbus/delayed-message-processing: OK /gdbus/nonce-tcp: GLib-GObject-WARNING **: invalid uninstantiatable type `(null)' in cast to `GDBusServer' aborting... Signed-off-by: David Zeuthen <davidz@redhat.com>
This commit is contained in:
parent
2be167f57c
commit
b3cf5cbd0b
@ -92,6 +92,7 @@ struct _GDBusServer
|
|||||||
|
|
||||||
GSocketListener *listener;
|
GSocketListener *listener;
|
||||||
gboolean is_using_listener;
|
gboolean is_using_listener;
|
||||||
|
gulong run_signal_handler_id;
|
||||||
|
|
||||||
/* The result of g_main_context_get_thread_default() when the object
|
/* The result of g_main_context_get_thread_default() when the object
|
||||||
* was created (the GObject _init() function) - this is used for delivery
|
* was created (the GObject _init() function) - this is used for delivery
|
||||||
@ -158,6 +159,9 @@ g_dbus_server_finalize (GObject *object)
|
|||||||
if (server->authentication_observer != NULL)
|
if (server->authentication_observer != NULL)
|
||||||
g_object_unref (server->authentication_observer);
|
g_object_unref (server->authentication_observer);
|
||||||
|
|
||||||
|
if (server->run_signal_handler_id > 0)
|
||||||
|
g_signal_handler_disconnect (server->listener, server->run_signal_handler_id);
|
||||||
|
|
||||||
if (server->listener != NULL)
|
if (server->listener != NULL)
|
||||||
g_object_unref (server->listener);
|
g_object_unref (server->listener);
|
||||||
|
|
||||||
@ -489,10 +493,10 @@ g_dbus_server_new_sync (const gchar *address,
|
|||||||
{
|
{
|
||||||
/* Right now we don't have any transport not using the listener... */
|
/* Right now we don't have any transport not using the listener... */
|
||||||
g_assert (server->is_using_listener);
|
g_assert (server->is_using_listener);
|
||||||
g_signal_connect (G_SOCKET_SERVICE (server->listener),
|
server->run_signal_handler_id = g_signal_connect (G_SOCKET_SERVICE (server->listener),
|
||||||
"run",
|
"run",
|
||||||
G_CALLBACK (on_run),
|
G_CALLBACK (on_run),
|
||||||
server);
|
server);
|
||||||
}
|
}
|
||||||
|
|
||||||
return server;
|
return server;
|
||||||
@ -605,6 +609,9 @@ g_dbus_server_stop (GDBusServer *server)
|
|||||||
return;
|
return;
|
||||||
/* Right now we don't have any transport not using the listener... */
|
/* Right now we don't have any transport not using the listener... */
|
||||||
g_assert (server->is_using_listener);
|
g_assert (server->is_using_listener);
|
||||||
|
g_assert (server->run_signal_handler_id > 0);
|
||||||
|
g_signal_handler_disconnect (server->listener, server->run_signal_handler_id);
|
||||||
|
server->run_signal_handler_id = 0;
|
||||||
g_socket_service_stop (G_SOCKET_SERVICE (server->listener));
|
g_socket_service_stop (G_SOCKET_SERVICE (server->listener));
|
||||||
server->active = FALSE;
|
server->active = FALSE;
|
||||||
g_object_notify (G_OBJECT (server), "active");
|
g_object_notify (G_OBJECT (server), "active");
|
||||||
|
Loading…
Reference in New Issue
Block a user