mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 06:56:14 +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;
|
||||
gboolean is_using_listener;
|
||||
gulong run_signal_handler_id;
|
||||
|
||||
/* The result of g_main_context_get_thread_default() when the object
|
||||
* 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)
|
||||
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)
|
||||
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... */
|
||||
g_assert (server->is_using_listener);
|
||||
g_signal_connect (G_SOCKET_SERVICE (server->listener),
|
||||
"run",
|
||||
G_CALLBACK (on_run),
|
||||
server);
|
||||
server->run_signal_handler_id = g_signal_connect (G_SOCKET_SERVICE (server->listener),
|
||||
"run",
|
||||
G_CALLBACK (on_run),
|
||||
server);
|
||||
}
|
||||
|
||||
return server;
|
||||
@ -605,6 +609,9 @@ g_dbus_server_stop (GDBusServer *server)
|
||||
return;
|
||||
/* Right now we don't have any transport not using the 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));
|
||||
server->active = FALSE;
|
||||
g_object_notify (G_OBJECT (server), "active");
|
||||
|
Loading…
Reference in New Issue
Block a user