worker: move display_channel_wait_for_migrate_data

Acked-by: Fabiano Fidêncio <fidencio@redhat.com>
This commit is contained in:
Marc-André Lureau 2013-09-17 16:36:29 +02:00 committed by Frediano Ziglio
parent 0e224d04fb
commit 1cbf6b3ab6
3 changed files with 32 additions and 31 deletions

View File

@ -807,3 +807,34 @@ int display_channel_add_drawable(DisplayChannel *display, Drawable *drawable)
return ret;
}
int display_channel_wait_for_migrate_data(DisplayChannel *display)
{
uint64_t end_time = red_get_monotonic_time() + DISPLAY_CLIENT_MIGRATE_DATA_TIMEOUT;
RedChannel *channel = &display->common.base;
RedChannelClient *rcc;
spice_debug(NULL);
spice_assert(channel->clients_num == 1);
rcc = SPICE_CONTAINEROF(ring_get_head(&channel->clients), RedChannelClient, channel_link);
spice_assert(red_channel_client_waits_for_migrate_data(rcc));
for (;;) {
red_channel_client_receive(rcc);
if (!red_channel_client_is_connected(rcc)) {
break;
}
if (!red_channel_client_waits_for_migrate_data(rcc)) {
return TRUE;
}
if (red_get_monotonic_time() > end_time) {
spice_warning("timeout");
red_channel_client_disconnect(rcc);
break;
}
usleep(DISPLAY_CLIENT_RETRY_INTERVAL);
}
return FALSE;
}

View File

@ -268,6 +268,7 @@ int display_channel_add_drawable (DisplayCha
Drawable *drawable);
void display_channel_current_flush (DisplayChannel *display,
int surface_id);
int display_channel_wait_for_migrate_data (DisplayChannel *display);
static inline int is_equal_path(SpicePath *path1, SpicePath *path2)
{

View File

@ -6911,37 +6911,6 @@ static void handle_dev_stop(void *opaque, void *payload)
}
}
static int display_channel_wait_for_migrate_data(DisplayChannel *display)
{
uint64_t end_time = red_get_monotonic_time() + DISPLAY_CLIENT_MIGRATE_DATA_TIMEOUT;
RedChannel *channel = &display->common.base;
RedChannelClient *rcc;
spice_debug(NULL);
spice_assert(channel->clients_num == 1);
rcc = SPICE_CONTAINEROF(ring_get_head(&channel->clients), RedChannelClient, channel_link);
spice_assert(red_channel_client_waits_for_migrate_data(rcc));
for (;;) {
red_channel_client_receive(rcc);
if (!red_channel_client_is_connected(rcc)) {
break;
}
if (!red_channel_client_waits_for_migrate_data(rcc)) {
return TRUE;
}
if (red_get_monotonic_time() > end_time) {
spice_warning("timeout");
red_channel_client_disconnect(rcc);
break;
}
usleep(DISPLAY_CLIENT_RETRY_INTERVAL);
}
return FALSE;
}
static void handle_dev_start(void *opaque, void *payload)
{
RedWorker *worker = opaque;