]> git.proxmox.com Git - mirror_qemu.git/commitdiff
io: stop incrementing reference in qio_task_get_source
authorDaniel P. Berrange <berrange@redhat.com>
Thu, 11 Aug 2016 17:11:04 +0000 (18:11 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Mon, 23 Jan 2017 15:32:18 +0000 (15:32 +0000)
Incrementing the reference in qio_task_get_source is
not necessary, since we're not running concurrently
with any other code touching the QIOTask. This
minimizes chances of further memory leaks.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
include/io/task.h
io/channel-socket.c
io/channel-tls.c
io/task.c
tests/test-io-task.c

index 42028cb424f2f56df33254938e305e04ddcd8262..c268eb0b8267053d7e79cd262c3a13e29362d9cb 100644 (file)
@@ -244,9 +244,10 @@ void qio_task_abort(QIOTask *task,
  * @task: the task struct
  *
  * Get the source object associated with the background
- * task. This returns a new reference to the object,
- * which the caller must released with object_unref()
- * when no longer required.
+ * task. The caller does not own a reference on the
+ * returned Object, and so should call object_ref()
+ * if it wants to keep the object pointer outside the
+ * lifetime of the QIOTask object.
  *
  * Returns: the source object
  */
index d7e03f62662d71f8821605ecbb725f7017e98f59..45df819a82ba3b913dbd31fa5d19571d9c2cf583 100644 (file)
@@ -168,7 +168,6 @@ static int qio_channel_socket_connect_worker(QIOTask *task,
                                           addr,
                                           errp);
 
-    object_unref(OBJECT(ioc));
     return ret;
 }
 
@@ -231,7 +230,6 @@ static int qio_channel_socket_listen_worker(QIOTask *task,
                                          addr,
                                          errp);
 
-    object_unref(OBJECT(ioc));
     return ret;
 }
 
@@ -309,7 +307,6 @@ static int qio_channel_socket_dgram_worker(QIOTask *task,
                                         data->remoteAddr,
                                         errp);
 
-    object_unref(OBJECT(ioc));
     return ret;
 }
 
index d24dc8c613ab494d701246367d685b93501bd1b4..cf3bcca7ed4f97022c306f554e94edd96a2b3ce0 100644 (file)
@@ -200,8 +200,6 @@ static gboolean qio_channel_tls_handshake_io(QIOChannel *ioc,
     qio_channel_tls_handshake_task(
        tioc, task);
 
-    object_unref(OBJECT(tioc));
-
     return FALSE;
 }
 
index c7f97a9b16e926c293a2390da75f59577e9cec3a..a763990d4754305f8c6682c614dd767889806960 100644 (file)
--- a/io/task.c
+++ b/io/task.c
@@ -156,6 +156,5 @@ void qio_task_abort(QIOTask *task,
 
 Object *qio_task_get_source(QIOTask *task)
 {
-    object_ref(task->source);
     return task->source;
 }
index e091c12e100cbc66cc505fa5b5c945f0da95c837..024eb585e4046e88961ba70ad9c9e1b496254a69 100644 (file)
@@ -76,7 +76,6 @@ static void test_task_complete(void)
     g_assert(obj == src);
 
     object_unref(obj);
-    object_unref(src);
 
     g_assert(data.source == obj);
     g_assert(data.err == NULL);