summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Toso <victortoso@redhat.com>2016-07-29 18:08:45 +0200
committerVictor Toso <victortoso@redhat.com>2016-08-10 13:58:29 +0200
commit27756bae62d6e6d9a64c396d7d21cf3c084130be (patch)
tree4be974df017905aad60c84a1c740216d0f27c962
parent2481df264d57b5992fc123cee57ed824465101aa (diff)
file-transfer: increase reference for channel-main
SpiceMainChannel uses the SpiceFileTransferTask reference given in the hash table provided by spice_file_transfer_task_create_tasks(). That means SpiceFileTransferTask is not holding a reference for itself but it relies on it due the async calls it provides. This patch increases the reference of each SpiceFileTransferTask for the hash table which will be unref'ed by channel-main in file_transfer_operation_task_finished(); the original reference is kept to SpiceFileTransferTask to be freed after the finish signal is emitted on spice_file_transfer_task_close_stream_cb(). This patch fixes some critical warnings as we have two g_object_unref but only one reference. Acked-by: Pavel Grunt <pgrunt@redhat.com>
-rw-r--r--src/spice-file-transfer-task.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/spice-file-transfer-task.c b/src/spice-file-transfer-task.c
index 4689b71..58340e3 100644
--- a/src/spice-file-transfer-task.c
+++ b/src/spice-file-transfer-task.c
@@ -325,6 +325,7 @@ void spice_file_transfer_task_completed(SpiceFileTransferTask *self,
self->pending = TRUE;
signal:
g_signal_emit(self, task_signals[SIGNAL_FINISHED], 0, self->error);
+ /* SpiceFileTransferTask unref is done after input stream is closed */
}
G_GNUC_INTERNAL
@@ -364,9 +365,10 @@ guint64 spice_file_transfer_task_get_bytes_read(SpiceFileTransferTask *self)
/* Helper function which only creates a SpiceFileTransferTask per GFile
* in @files and returns a HashTable mapping task-id to the task itself
- * Note that the HashTable does not free its values upon destruction:
- * The SpiceFileTransferTask reference created here should be freed by
- * spice_file_transfer_task_completed */
+ * The SpiceFileTransferTask created here has two references, one should be
+ * freed by spice_file_transfer_task_close_stream_cb() after
+ * spice_file_transfer_task_completed() is called and the other reference
+ * belongs to the caller and should be freed upon GHashTable destruction */
G_GNUC_INTERNAL
GHashTable *spice_file_transfer_task_create_tasks(GFile **files,
SpiceMainChannel *channel,
@@ -385,7 +387,7 @@ GHashTable *spice_file_transfer_task_create_tasks(GFile **files,
xfer_task = spice_file_transfer_task_new(channel, files[i], flags, cancellable);
task_id = spice_file_transfer_task_get_id(xfer_task);
- g_hash_table_insert(xfer_ht, GUINT_TO_POINTER(task_id), xfer_task);
+ g_hash_table_insert(xfer_ht, GUINT_TO_POINTER(task_id), g_object_ref(xfer_task));
}
return xfer_ht;
}