aboutsummaryrefslogtreecommitdiff
path: root/io
diff options
context:
space:
mode:
authorDaniel P. Berrange <berrange@redhat.com>2016-08-11 17:38:07 +0100
committerDaniel P. Berrange <berrange@redhat.com>2017-01-23 15:32:19 +0000
commit59de517d8d482416a079da7ee8344187d513d4a4 (patch)
treef24cf5539b7780c8a794bcba796cb2ab4e78c37f /io
parent60e705c51c66373f78e536e0462744a610c27cf6 (diff)
downloadqemu-59de517d8d482416a079da7ee8344187d513d4a4.zip
qemu-59de517d8d482416a079da7ee8344187d513d4a4.tar.gz
qemu-59de517d8d482416a079da7ee8344187d513d4a4.tar.bz2
io: remove Error parameter from QIOTask thread worker
Now that task objects have a directly associated error, there's no need for an an Error **errp parameter to the QIOTask thread worker function. It already has a QIOTask object, so can directly set the error on it. Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Diffstat (limited to 'io')
-rw-r--r--io/channel-socket.c41
-rw-r--r--io/task.c10
2 files changed, 17 insertions, 34 deletions
diff --git a/io/channel-socket.c b/io/channel-socket.c
index 45df819..f385233 100644
--- a/io/channel-socket.c
+++ b/io/channel-socket.c
@@ -156,19 +156,16 @@ int qio_channel_socket_connect_sync(QIOChannelSocket *ioc,
}
-static int qio_channel_socket_connect_worker(QIOTask *task,
- Error **errp,
- gpointer opaque)
+static void qio_channel_socket_connect_worker(QIOTask *task,
+ gpointer opaque)
{
QIOChannelSocket *ioc = QIO_CHANNEL_SOCKET(qio_task_get_source(task));
SocketAddress *addr = opaque;
- int ret;
+ Error *err = NULL;
- ret = qio_channel_socket_connect_sync(ioc,
- addr,
- errp);
+ qio_channel_socket_connect_sync(ioc, addr, &err);
- return ret;
+ qio_task_set_error(task, err);
}
@@ -218,19 +215,16 @@ int qio_channel_socket_listen_sync(QIOChannelSocket *ioc,
}
-static int qio_channel_socket_listen_worker(QIOTask *task,
- Error **errp,
- gpointer opaque)
+static void qio_channel_socket_listen_worker(QIOTask *task,
+ gpointer opaque)
{
QIOChannelSocket *ioc = QIO_CHANNEL_SOCKET(qio_task_get_source(task));
SocketAddress *addr = opaque;
- int ret;
+ Error *err = NULL;
- ret = qio_channel_socket_listen_sync(ioc,
- addr,
- errp);
+ qio_channel_socket_listen_sync(ioc, addr, &err);
- return ret;
+ qio_task_set_error(task, err);
}
@@ -293,21 +287,18 @@ static void qio_channel_socket_dgram_worker_free(gpointer opaque)
g_free(data);
}
-static int qio_channel_socket_dgram_worker(QIOTask *task,
- Error **errp,
- gpointer opaque)
+static void qio_channel_socket_dgram_worker(QIOTask *task,
+ gpointer opaque)
{
QIOChannelSocket *ioc = QIO_CHANNEL_SOCKET(qio_task_get_source(task));
struct QIOChannelSocketDGramWorkerData *data = opaque;
- int ret;
+ Error *err = NULL;
/* socket_dgram() blocks in DNS lookups, so we must use a thread */
- ret = qio_channel_socket_dgram_sync(ioc,
- data->localAddr,
- data->remoteAddr,
- errp);
+ qio_channel_socket_dgram_sync(ioc, data->localAddr,
+ data->remoteAddr, &err);
- return ret;
+ qio_task_set_error(task, err);
}
diff --git a/io/task.c b/io/task.c
index 42e1a75..60bf1a9 100644
--- a/io/task.c
+++ b/io/task.c
@@ -77,8 +77,6 @@ struct QIOTaskThreadData {
QIOTaskWorker worker;
gpointer opaque;
GDestroyNotify destroy;
- Error *err;
- int ret;
};
@@ -87,9 +85,6 @@ static gboolean gio_task_thread_result(gpointer opaque)
struct QIOTaskThreadData *data = opaque;
trace_qio_task_thread_result(data->task);
- if (data->err) {
- qio_task_set_error(data->task, data->err);
- }
qio_task_complete(data->task);
if (data->destroy) {
@@ -107,10 +102,7 @@ static gpointer qio_task_thread_worker(gpointer opaque)
struct QIOTaskThreadData *data = opaque;
trace_qio_task_thread_run(data->task);
- data->ret = data->worker(data->task, &data->err, data->opaque);
- if (data->ret < 0 && data->err == NULL) {
- error_setg(&data->err, "Task worker failed but did not set an error");
- }
+ data->worker(data->task, data->opaque);
/* We're running in the background thread, and must only
* ever report the task results in the main event loop