mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-04 10:16:17 +01:00
gnetworkmonitornetlink: Close the socket after disconnecting its GSources
`read_netlink_messages()` is the callback attached to the netlink socket (G_IO_IN). It calls `g_socket_receive_message()`. There is a race condition that if the socket is closed while there is a pending call, we will try to receive on a closed socket, which fails. To avoid this, we switch the order of the operations around: first destroy the source and then close the socket.
This commit is contained in:
parent
8b26ad22d4
commit
7e413f810c
@ -435,12 +435,6 @@ g_network_monitor_netlink_finalize (GObject *object)
|
||||
{
|
||||
GNetworkMonitorNetlink *nl = G_NETWORK_MONITOR_NETLINK (object);
|
||||
|
||||
if (nl->priv->sock)
|
||||
{
|
||||
g_socket_close (nl->priv->sock, NULL);
|
||||
g_object_unref (nl->priv->sock);
|
||||
}
|
||||
|
||||
if (nl->priv->source)
|
||||
{
|
||||
g_source_destroy (nl->priv->source);
|
||||
@ -453,6 +447,12 @@ g_network_monitor_netlink_finalize (GObject *object)
|
||||
g_source_unref (nl->priv->dump_source);
|
||||
}
|
||||
|
||||
if (nl->priv->sock)
|
||||
{
|
||||
g_socket_close (nl->priv->sock, NULL);
|
||||
g_object_unref (nl->priv->sock);
|
||||
}
|
||||
|
||||
g_clear_pointer (&nl->priv->context, g_main_context_unref);
|
||||
g_clear_pointer (&nl->priv->dump_networks, g_ptr_array_unref);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user