diff --git a/gio/gsocket.c b/gio/gsocket.c index e7f210139..4961f6f51 100644 --- a/gio/gsocket.c +++ b/gio/gsocket.c @@ -3285,6 +3285,7 @@ g_socket_close (GSocket *socket, break; } + socket->priv->fd = -1; socket->priv->connected_read = FALSE; socket->priv->connected_write = FALSE; socket->priv->closed = TRUE; diff --git a/gio/tests/socket.c b/gio/tests/socket.c index a5b25731f..1dba97048 100644 --- a/gio/tests/socket.c +++ b/gio/tests/socket.c @@ -1197,6 +1197,10 @@ test_fd_reuse (void) g_socket_close (data->server, &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 (client); g_object_unref (client2);