mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-25 21:46:14 +01:00
gdbusserver: Keep a strong reference to the server in callbacks
The `on_run()` function could be executed in any worker thread from the `GThreadedSocketListener`, but didn’t previously hold a strong reference to the `GDBusServer`, which meant the server could be finalised in another thread while `on_run()` was still running. This was not ideal. Hold a strong reference to the `GDBusServer` while the socket listener is listening, i.e. between every paired call to `g_dbus_server_start()` and `g_dbus_server_stop()`. Signed-off-by: Philip Withnall <withnall@endlessm.com> Fixes: #1318
This commit is contained in:
parent
8e32b8e87f
commit
0c07e672a2
@ -613,6 +613,12 @@ g_dbus_server_start (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);
|
||||||
|
server->run_signal_handler_id = g_signal_connect_data (G_SOCKET_SERVICE (server->listener),
|
||||||
|
"run",
|
||||||
|
G_CALLBACK (on_run),
|
||||||
|
g_object_ref (server),
|
||||||
|
(GClosureNotify) g_object_unref,
|
||||||
|
0 /* flags */);
|
||||||
g_socket_service_start (G_SOCKET_SERVICE (server->listener));
|
g_socket_service_start (G_SOCKET_SERVICE (server->listener));
|
||||||
server->active = TRUE;
|
server->active = TRUE;
|
||||||
g_object_notify (G_OBJECT (server), "active");
|
g_object_notify (G_OBJECT (server), "active");
|
||||||
@ -1162,15 +1168,7 @@ initable_init (GInitable *initable,
|
|||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
if (last_error != NULL)
|
g_clear_error (&last_error);
|
||||||
g_error_free (last_error);
|
|
||||||
|
|
||||||
/* Right now we don't have any transport not using the listener... */
|
|
||||||
g_assert (server->is_using_listener);
|
|
||||||
server->run_signal_handler_id = g_signal_connect (G_SOCKET_SERVICE (server->listener),
|
|
||||||
"run",
|
|
||||||
G_CALLBACK (on_run),
|
|
||||||
server);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user