Add red_channel_client_(set|is)_destroying()

Encapsulate the structure a bit more and avoid poking into it from other
class implementations. Getting ready to split RedChannelClient out to a
separate file.
This commit is contained in:
Jonathon Jongsma 2016-08-19 16:52:08 -05:00
parent 2fa1c1e3fd
commit 7b8087a71d
3 changed files with 14 additions and 2 deletions

View File

@ -2111,7 +2111,7 @@ void red_client_destroy(RedClient *client)
// is not synchronous.
rcc = link->data;
channel = red_channel_client_get_channel(rcc);
rcc->destroying = 1;
red_channel_client_set_destroying(rcc);
// some channels may be in other threads. However we currently
// assume disconnect is synchronous (we changed the dispatcher
// to wait for disconnection)
@ -2448,3 +2448,13 @@ RedChannel* red_channel_client_get_channel(RedChannelClient *rcc)
{
return rcc->channel;
}
gboolean red_channel_client_is_destroying(RedChannelClient *rcc)
{
return rcc->destroying;
}
void red_channel_client_set_destroying(RedChannelClient *rcc)
{
rcc->destroying = TRUE;
}

View File

@ -629,5 +629,7 @@ int red_channel_wait_all_sent(RedChannel *channel,
int64_t timeout);
void red_channel_client_disconnect_if_pending_send(RedChannelClient *rcc);
RedChannel* red_channel_client_get_channel(RedChannelClient *rcc);
gboolean red_channel_client_is_destroying(RedChannelClient *rcc);
void red_channel_client_set_destroying(RedChannelClient *rcc);
#endif

View File

@ -306,7 +306,7 @@ static void spicevmc_red_channel_client_on_disconnect(RedChannelClient *rcc)
/* Don't destroy the rcc if it is already being destroyed, as then
red_client_destroy/red_channel_client_destroy will already do this! */
if (!rcc->destroying)
if (!red_channel_client_is_destroying(rcc))
red_channel_client_destroy(rcc);
state->rcc = NULL;