Commit c16a0b53 authored by Christian Hergert's avatar Christian Hergert

socket: set fd field to -1 after closing socket

This ensures that g_socket_get_fd() will return -1 after the socket has
been closed.

https://bugzilla.gnome.org/show_bug.cgi?id=765959
parent 0cd3d574
...@@ -3285,6 +3285,7 @@ g_socket_close (GSocket *socket, ...@@ -3285,6 +3285,7 @@ g_socket_close (GSocket *socket,
break; break;
} }
socket->priv->fd = -1;
socket->priv->connected_read = FALSE; socket->priv->connected_read = FALSE;
socket->priv->connected_write = FALSE; socket->priv->connected_write = FALSE;
socket->priv->closed = TRUE; socket->priv->closed = TRUE;
......
...@@ -1197,6 +1197,10 @@ test_fd_reuse (void) ...@@ -1197,6 +1197,10 @@ test_fd_reuse (void)
g_socket_close (data->server, &error); g_socket_close (data->server, &error);
g_assert_no_error (error); g_assert_no_error (error);
g_assert_cmpint (g_socket_get_fd (client), ==, -1);
g_assert_cmpint (g_socket_get_fd (client2), ==, -1);
g_assert_cmpint (g_socket_get_fd (data->server), ==, -1);
g_object_unref (data->server); g_object_unref (data->server);
g_object_unref (client); g_object_unref (client);
g_object_unref (client2); g_object_unref (client2);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment