From 1078dc04edc406950e5f6d91bae456411eaa4a47 Mon Sep 17 00:00:00 2001 From: Alon Levy Date: Tue, 23 Aug 2011 14:13:16 +0300 Subject: [PATCH] server/reds: reds_client_disconnect: remove wrong check for reds_main_channel_connected The "channel->disconnecting" parameter already protects against recursion. Removed fixed TODOs. --- server/reds.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/server/reds.c b/server/reds.c index f629471b..d140afd4 100644 --- a/server/reds.c +++ b/server/reds.c @@ -606,18 +606,15 @@ static int reds_main_channel_connected(void) void reds_client_disconnect(RedClient *client) { - // TODO: rename reds_main_channel_connected, or really set main_channel to NULL on disconnect, - // though still, it is not a reason not to disconnect the rest of the channels - if (!reds_main_channel_connected() || client->disconnecting) { - /* case of recursion (main_channel_client_on_disconnect-> - * reds_client_disconnect->red_client_destroy-disconnecting) { return; } red_printf(""); - // why is "disconnecting" even needed? it is synchronic, even in the dispatcher we are now waiting for disconnection - // Are there recursive calls? Maybe from main_channel? + /* disconnecting is set to prevent recursion because of the following: + * main_channel_client_on_disconnect-> + * reds_client_disconnect->red_client_destroy->main_channel... + */ client->disconnecting = TRUE; // TODO: we need to handle agent properly for all clients!!!! (e.g., cut and paste, how?) @@ -629,7 +626,6 @@ void reds_client_disconnect(RedClient *client) // TODO: we need to handle agent properly for all clients!!!! (e.g., cut and paste, how? Maybe throw away messages // if we are in the middle of one from another client) - // We shouldn't initialize the agent when there are still clients connected if (reds->num_clients == 0) { /* Reset write filter to start with clean state on client reconnect */ agent_msg_filter_init(&reds->agent_state.write_filter, agent_copypaste,