reds: s/red_client_disconnect/red_channel_client_shutdown inside callbacks

When we want to disconnect the main channel from a callback, it is
safer to use red_channel_client_shutdown, instead of directly
destroying the client. It is also more consistent with how other
channels treat errors.
red_channel_client_shutdown will trigger socket error in the main channel.
Then, main_channel_client_on_disconnect will be called,
and eventually, main_dispatcher_client_disconnect.

I didn't replace calls to reds_disconnect/reds_client_disconnect in
places where those calls were safe && that might need immediate client
disconnection.
This commit is contained in:
Yonit Halperin 2013-07-25 14:25:24 -04:00
parent 8490f83e1f
commit 46c2ce8f1a

View File

@ -879,7 +879,8 @@ static void vdi_port_on_free_self_token(void *opaque)
static void vdi_port_remove_client(RedClient *client, void *opaque)
{
reds_client_disconnect(client);
red_channel_client_shutdown(main_channel_client_get_base(
red_client_get_main(client)));
}
/****************************************************************************/
@ -1009,7 +1010,7 @@ void reds_on_main_agent_start(MainChannelClient *mcc, uint32_t num_tokens)
if (!client_added) {
spice_warning("failed to add client to agent");
reds_client_disconnect(rcc->client);
red_channel_client_shutdown(rcc);
return;
}
} else {
@ -1126,7 +1127,7 @@ void reds_on_main_agent_data(MainChannelClient *mcc, void *message, size_t size)
reds_on_main_agent_monitors_config(mcc, message, size);
return;
case AGENT_MSG_FILTER_PROTO_ERROR:
reds_disconnect();
red_channel_client_shutdown(main_channel_client_get_base(mcc));
return;
}