From e7a5e2976fe8db46ef4cf22f63b0ffd87ca68b63 Mon Sep 17 00:00:00 2001 From: Gergely POLONKAI Date: Fri, 23 Mar 2012 14:38:36 +0100 Subject: [PATCH] Added socket_source to wmudClient struct Added socket_source GSource to the wmudClient struct, so it can be removed upon connection closing. It sometimes caused a bug. Signed-off-by: Gergely POLONKAI --- src/networking.c | 2 ++ src/wmud_types.h | 1 + 2 files changed, 3 insertions(+) diff --git a/src/networking.c b/src/networking.c index 512f4d7..87892c1 100644 --- a/src/networking.c +++ b/src/networking.c @@ -35,6 +35,7 @@ wmud_client_close(wmudClient *client, gboolean send_goodbye) wmud_player_free(&(client->player)); if (client->buffer) g_string_free(client->buffer, TRUE); + g_source_destroy(client->socket_source); g_free(client); } @@ -161,6 +162,7 @@ game_source_callback(GSocket *socket, GIOCondition condition, struct AcceptData clients = g_slist_prepend(clients, client_data); client_source = g_socket_create_source(client_socket, G_IO_IN | G_IO_OUT | G_IO_PRI | G_IO_ERR | G_IO_HUP | G_IO_NVAL, NULL); + client_data->socket_source = client_source; g_source_set_callback(client_source, (GSourceFunc)wmud_client_callback, client_data, NULL); g_source_attach(client_source, accept_data->context); g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, "New connection."); diff --git a/src/wmud_types.h b/src/wmud_types.h index 4a38aae..a940e78 100644 --- a/src/wmud_types.h +++ b/src/wmud_types.h @@ -28,6 +28,7 @@ typedef struct _wmudPlayer { typedef struct _wmudClient { GSocket *socket; + GSource *socket_source; GString *buffer; wmudClientState state; gboolean authenticated;