From: "Daniel P. Berrange" <berrange@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH v2 2/8] io: stop incrementing reference in qio_task_get_source
Date: Mon, 9 Jan 2017 15:39:08 +0000 [thread overview]
Message-ID: <20170109153914.27424-3-berrange@redhat.com> (raw)
In-Reply-To: <20170109153914.27424-1-berrange@redhat.com>
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 | 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
next prev parent reply other threads:[~2017-01-09 15:39 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-09 15:39 [Qemu-devel] [PATCH v2 0/8] io: enable DNS resolving separately of socket create Daniel P. Berrange
2017-01-09 15:39 ` [Qemu-devel] [PATCH v2 1/8] sockets: add ability to disable DNS resolution for InetSocketAddress Daniel P. Berrange
2017-01-10 14:25 ` Eric Blake
2017-01-09 15:39 ` Daniel P. Berrange [this message]
2017-01-09 15:39 ` [Qemu-devel] [PATCH v2 3/8] io: fix typo in docs for QIOTask Daniel P. Berrange
2017-01-09 15:39 ` [Qemu-devel] [PATCH v2 4/8] io: add ability to associate an opaque "result" with with a task Daniel P. Berrange
2017-01-09 15:39 ` [Qemu-devel] [PATCH v2 5/8] io: add ability to associate an error " Daniel P. Berrange
2017-01-10 14:55 ` Eric Blake
2017-01-09 15:39 ` [Qemu-devel] [PATCH v2 6/8] io: change the QIOTask callback signature Daniel P. Berrange
2017-01-09 15:39 ` [Qemu-devel] [PATCH v2 7/8] io: remove Error parameter from QIOTask thread worker Daniel P. Berrange
2017-01-09 15:39 ` [Qemu-devel] [PATCH v2 8/8] io: introduce a DNS resolver API Daniel P. Berrange
2017-01-10 15:01 ` Eric Blake
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170109153914.27424-3-berrange@redhat.com \
--to=berrange@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).