From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34420) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cQc2h-0005jA-R6 for qemu-devel@nongnu.org; Mon, 09 Jan 2017 10:39:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cQc2g-0000jV-Nm for qemu-devel@nongnu.org; Mon, 09 Jan 2017 10:39:27 -0500 Received: from mx1.redhat.com ([209.132.183.28]:43250) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cQc2g-0000iz-FG for qemu-devel@nongnu.org; Mon, 09 Jan 2017 10:39:26 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9A34A8F28E for ; Mon, 9 Jan 2017 15:39:26 +0000 (UTC) From: "Daniel P. Berrange" Date: Mon, 9 Jan 2017 15:39:08 +0000 Message-Id: <20170109153914.27424-3-berrange@redhat.com> In-Reply-To: <20170109153914.27424-1-berrange@redhat.com> References: <20170109153914.27424-1-berrange@redhat.com> Subject: [Qemu-devel] [PATCH v2 2/8] io: stop incrementing reference in qio_task_get_source List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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 Signed-off-by: Daniel P. Berrange --- include/io/task.h | 7 ++++--- io/channel-socket.c | 3 --- io/channel-tls.c | 2 -- io/task.c | 1 - tests/test-io-task.c | 1 - 5 files changed, 4 insertions(+), 10 deletions(-) diff --git a/include/io/task.h b/include/io/task.h index 42028cb..c268eb0 100644 --- a/include/io/task.h +++ b/include/io/task.h @@ -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 */ diff --git a/io/channel-socket.c b/io/channel-socket.c index d7e03f6..45df819 100644 --- a/io/channel-socket.c +++ b/io/channel-socket.c @@ -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; } diff --git a/io/channel-tls.c b/io/channel-tls.c index d24dc8c..cf3bcca 100644 --- a/io/channel-tls.c +++ b/io/channel-tls.c @@ -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; } diff --git a/io/task.c b/io/task.c index c7f97a9..a763990 100644 --- 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; } diff --git a/tests/test-io-task.c b/tests/test-io-task.c index e091c12..024eb58 100644 --- a/tests/test-io-task.c +++ b/tests/test-io-task.c @@ -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); -- 2.9.3