|
|
6a5638 |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
6a5638 |
From: Victor Toso <me@victortoso.com>
|
|
|
6a5638 |
Date: Wed, 8 Feb 2017 09:59:51 +0100
|
|
|
6a5638 |
Subject: [PATCH] file-xfer: avoid g_hash_table_iter_* when changing the
|
|
|
6a5638 |
GHashTable
|
|
|
6a5638 |
|
|
|
6a5638 |
Using g_hash_table_iter_init() and g_hash_table_iter_next() here is
|
|
|
6a5638 |
bad as spice_file_transfer_task_completed() will emit "finished"
|
|
|
6a5638 |
signal from SpiceFileTransferTask resulting in the original GHashTable
|
|
|
6a5638 |
to be changed in file_transfer_operation_task_finished()
|
|
|
6a5638 |
|
|
|
6a5638 |
Debug will show:
|
|
|
6a5638 |
GSpice-DEBUG: spice-file-transfer-task.c:303 File bigfile2 xfer
|
|
|
6a5638 |
failed: Agent connection closed
|
|
|
6a5638 |
|
|
|
6a5638 |
WARNING **: Agent connection closed
|
|
|
6a5638 |
|
|
|
6a5638 |
GLib-CRITICAL **: g_hash_table_iter_next: assertion 'ri->version ==
|
|
|
6a5638 |
ri->hash_table->version' failed
|
|
|
6a5638 |
|
|
|
6a5638 |
Reported-by: Pavel Grunt <pgrunt@redhat.com>
|
|
|
6a5638 |
Signed-off-by: Victor Toso <victortoso@redhat.com>
|
|
|
6a5638 |
Acked-by: Pavel Grunt <pgrunt@redhat.com>
|
|
|
6a5638 |
(cherry picked from commit 01bb9bb30517b0ea3bdb230d40b2835c53a9cf59)
|
|
|
6a5638 |
---
|
|
|
6a5638 |
src/channel-main.c | 19 ++++++++++++-------
|
|
|
6a5638 |
1 file changed, 12 insertions(+), 7 deletions(-)
|
|
|
6a5638 |
|
|
|
6a5638 |
diff --git a/src/channel-main.c b/src/channel-main.c
|
|
|
6a5638 |
index 72ca712..0a4435e 100644
|
|
|
6a5638 |
--- a/src/channel-main.c
|
|
|
6a5638 |
+++ b/src/channel-main.c
|
|
|
6a5638 |
@@ -2915,19 +2915,23 @@ static void file_transfer_operation_free(FileTransferOperation *xfer_op)
|
|
|
6a5638 |
|
|
|
6a5638 |
static void spice_main_channel_reset_all_xfer_operations(SpiceMainChannel *channel)
|
|
|
6a5638 |
{
|
|
|
6a5638 |
- GHashTableIter iter_all_xfer_tasks;
|
|
|
6a5638 |
- gpointer key, value;
|
|
|
6a5638 |
+ GList *it, *keys;
|
|
|
6a5638 |
|
|
|
6a5638 |
/* Mark each of SpiceFileTransferTask as completed due error */
|
|
|
6a5638 |
- g_hash_table_iter_init(&iter_all_xfer_tasks, channel->priv->file_xfer_tasks);
|
|
|
6a5638 |
- while (g_hash_table_iter_next(&iter_all_xfer_tasks, &key, &value)) {
|
|
|
6a5638 |
- FileTransferOperation *xfer_op = value;
|
|
|
6a5638 |
- SpiceFileTransferTask *xfer_task = g_hash_table_lookup(xfer_op->xfer_task, key);
|
|
|
6a5638 |
+ keys = g_hash_table_get_keys(channel->priv->file_xfer_tasks);
|
|
|
6a5638 |
+ for (it = keys; it != NULL; it = it->next) {
|
|
|
6a5638 |
+ FileTransferOperation *xfer_op;
|
|
|
6a5638 |
+ SpiceFileTransferTask *xfer_task;
|
|
|
6a5638 |
GError *error;
|
|
|
6a5638 |
|
|
|
6a5638 |
+ xfer_op = g_hash_table_lookup(channel->priv->file_xfer_tasks, it->data);
|
|
|
6a5638 |
+ if (xfer_op == NULL)
|
|
|
6a5638 |
+ continue;
|
|
|
6a5638 |
+
|
|
|
6a5638 |
+ xfer_task = g_hash_table_lookup(xfer_op->xfer_task, it->data);
|
|
|
6a5638 |
if (xfer_task == NULL) {
|
|
|
6a5638 |
spice_warning("(reset-all) can't complete task %u - completed already?",
|
|
|
6a5638 |
- GPOINTER_TO_UINT(key));
|
|
|
6a5638 |
+ GPOINTER_TO_UINT(it->data));
|
|
|
6a5638 |
continue;
|
|
|
6a5638 |
}
|
|
|
6a5638 |
|
|
|
6a5638 |
@@ -2935,6 +2939,7 @@ static void spice_main_channel_reset_all_xfer_operations(SpiceMainChannel *chann
|
|
|
6a5638 |
"Agent connection closed");
|
|
|
6a5638 |
spice_file_transfer_task_completed(xfer_task, error);
|
|
|
6a5638 |
}
|
|
|
6a5638 |
+ g_list_free(keys);
|
|
|
6a5638 |
}
|
|
|
6a5638 |
|
|
|
6a5638 |
static SpiceFileTransferTask *spice_main_channel_find_xfer_task_by_task_id(SpiceMainChannel *channel,
|