summaryrefslogtreecommitdiffstats
path: root/server/reds.c
diff options
context:
space:
mode:
authorYonit Halperin <yhalperi@redhat.com>2012-08-14 15:42:36 +0300
committerYonit Halperin <yhalperi@redhat.com>2012-08-27 09:13:08 +0300
commit9c6a49c364699ea20d3603572fa5b829612d8914 (patch)
treee45fe05e5f7d82f84fed916af12d94efe1b756bc /server/reds.c
parenta180fc5e0b1efdecc3101fbe04d9478e18a940ec (diff)
downloadspice-9c6a49c364699ea20d3603572fa5b829612d8914.tar.gz
spice-9c6a49c364699ea20d3603572fa5b829612d8914.tar.xz
spice-9c6a49c364699ea20d3603572fa5b829612d8914.zip
char_device: don't connect a migrated client if the state of the device might have changed since it was created
If reading/writing from the device have occured before migration data has arrived, the migration data might no longer be relvant, and we disconnect the client.
Diffstat (limited to 'server/reds.c')
-rw-r--r--server/reds.c44
1 files changed, 30 insertions, 14 deletions
diff --git a/server/reds.c b/server/reds.c
index ba42b88a..8ad8425d 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -1111,13 +1111,21 @@ void reds_on_main_agent_start(MainChannelClient *mcc, uint32_t num_tokens)
* flow control, but will have no other problem.
*/
if (!spice_char_device_client_exists(dev_state, rcc->client)) {
- spice_char_device_client_add(dev_state,
- rcc->client,
- TRUE, /* flow control */
- REDS_VDI_PORT_NUM_RECEIVE_BUFFS,
- REDS_AGENT_WINDOW_SIZE,
- num_tokens,
- red_channel_client_waits_for_migrate_data(rcc));
+ int client_added;
+
+ client_added = spice_char_device_client_add(dev_state,
+ rcc->client,
+ TRUE, /* flow control */
+ REDS_VDI_PORT_NUM_RECEIVE_BUFFS,
+ REDS_AGENT_WINDOW_SIZE,
+ num_tokens,
+ red_channel_client_waits_for_migrate_data(rcc));
+
+ if (!client_added) {
+ spice_warning("failed to add client to agent");
+ reds_client_disconnect(rcc->client);
+ return;
+ }
} else {
spice_char_device_send_to_client_tokens_set(dev_state,
rcc->client,
@@ -3580,13 +3588,21 @@ static SpiceCharDeviceState *attach_to_red_agent(SpiceCharDeviceInstance *sin)
} else {
spice_debug("waiting for migration data");
if (!spice_char_device_client_exists(reds->agent_state.base, reds_get_client())) {
- spice_char_device_client_add(reds->agent_state.base,
- reds_get_client(),
- TRUE, /* flow control */
- REDS_VDI_PORT_NUM_RECEIVE_BUFFS,
- REDS_AGENT_WINDOW_SIZE,
- ~0,
- TRUE);
+ int client_added;
+
+ client_added = spice_char_device_client_add(reds->agent_state.base,
+ reds_get_client(),
+ TRUE, /* flow control */
+ REDS_VDI_PORT_NUM_RECEIVE_BUFFS,
+ REDS_AGENT_WINDOW_SIZE,
+ ~0,
+ TRUE);
+
+ if (!client_added) {
+ spice_warning("failed to add client to agent");
+ reds_disconnect();
+ }
+
}
}
return state->base;