io: change the QIOTask callback signature
Currently the QIOTaskFunc signature takes an Object * for the source, and an Error * for any error. We also need to be able to provide a result pointer. Rather than continue to add parameters to QIOTaskFunc, remove the existing ones and simply pass the QIOTask object instead. This has methods to access all the other data items required in the callback impl. Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
1a447e4f02
commit
60e705c51c
@ -26,8 +26,7 @@
|
|||||||
|
|
||||||
typedef struct QIOTask QIOTask;
|
typedef struct QIOTask QIOTask;
|
||||||
|
|
||||||
typedef void (*QIOTaskFunc)(Object *source,
|
typedef void (*QIOTaskFunc)(QIOTask *task,
|
||||||
Error *err,
|
|
||||||
gpointer opaque);
|
gpointer opaque);
|
||||||
|
|
||||||
typedef int (*QIOTaskWorker)(QIOTask *task,
|
typedef int (*QIOTaskWorker)(QIOTask *task,
|
||||||
@ -44,7 +43,7 @@ typedef int (*QIOTaskWorker)(QIOTask *task,
|
|||||||
* a public API which accepts a task callback:
|
* a public API which accepts a task callback:
|
||||||
*
|
*
|
||||||
* <example>
|
* <example>
|
||||||
* <title>Task callback function signature</title>
|
* <title>Task function signature</title>
|
||||||
* <programlisting>
|
* <programlisting>
|
||||||
* void myobject_operation(QMyObject *obj,
|
* void myobject_operation(QMyObject *obj,
|
||||||
* QIOTaskFunc *func,
|
* QIOTaskFunc *func,
|
||||||
@ -57,12 +56,36 @@ typedef int (*QIOTaskWorker)(QIOTask *task,
|
|||||||
* is data to pass to it. The optional 'notify' function is used
|
* is data to pass to it. The optional 'notify' function is used
|
||||||
* to free 'opaque' when no longer needed.
|
* to free 'opaque' when no longer needed.
|
||||||
*
|
*
|
||||||
* Now, lets say the implementation of this method wants to set
|
* When the operation completes, the 'func' callback will be
|
||||||
* a timer to run once a second checking for completion of some
|
* invoked, allowing the calling code to determine the result
|
||||||
* activity. It would do something like
|
* of the operation. An example QIOTaskFunc implementation may
|
||||||
|
* look like
|
||||||
*
|
*
|
||||||
* <example>
|
* <example>
|
||||||
* <title>Task callback function implementation</title>
|
* <title>Task callback implementation</title>
|
||||||
|
* <programlisting>
|
||||||
|
* static void myobject_operation_notify(QIOTask *task,
|
||||||
|
* gpointer opaque)
|
||||||
|
* {
|
||||||
|
* Error *err = NULL;
|
||||||
|
* if (qio_task_propagate_error(task, &err)) {
|
||||||
|
* ...deal with the failure...
|
||||||
|
* error_free(err);
|
||||||
|
* } else {
|
||||||
|
* QMyObject *src = QMY_OBJECT(qio_task_get_source(task));
|
||||||
|
* ...deal with the completion...
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* </programlisting>
|
||||||
|
* </example>
|
||||||
|
*
|
||||||
|
* Now, lets say the implementation of the method using the
|
||||||
|
* task wants to set a timer to run once a second checking
|
||||||
|
* for completion of some activity. It would do something
|
||||||
|
* like
|
||||||
|
*
|
||||||
|
* <example>
|
||||||
|
* <title>Task function implementation</title>
|
||||||
* <programlisting>
|
* <programlisting>
|
||||||
* void myobject_operation(QMyObject *obj,
|
* void myobject_operation(QMyObject *obj,
|
||||||
* QIOTaskFunc *func,
|
* QIOTaskFunc *func,
|
||||||
@ -102,8 +125,8 @@ typedef int (*QIOTaskWorker)(QIOTask *task,
|
|||||||
*
|
*
|
||||||
* ...check something important...
|
* ...check something important...
|
||||||
* if (err) {
|
* if (err) {
|
||||||
* qio_task_abort(task, err);
|
* qio_task_set_error(task, err);
|
||||||
* error_free(task);
|
* qio_task_complete(task);
|
||||||
* return FALSE;
|
* return FALSE;
|
||||||
* } else if (...work is completed ...) {
|
* } else if (...work is completed ...) {
|
||||||
* qio_task_complete(task);
|
* qio_task_complete(task);
|
||||||
@ -115,6 +138,10 @@ typedef int (*QIOTaskWorker)(QIOTask *task,
|
|||||||
* </programlisting>
|
* </programlisting>
|
||||||
* </example>
|
* </example>
|
||||||
*
|
*
|
||||||
|
* The 'qio_task_complete' call in this method will trigger
|
||||||
|
* the callback func 'myobject_operation_notify' shown
|
||||||
|
* earlier to deal with the results.
|
||||||
|
*
|
||||||
* Once this function returns false, object_unref will be called
|
* Once this function returns false, object_unref will be called
|
||||||
* automatically on the task causing it to be released and the
|
* automatically on the task causing it to be released and the
|
||||||
* ref on QMyObject dropped too.
|
* ref on QMyObject dropped too.
|
||||||
@ -187,8 +214,8 @@ typedef int (*QIOTaskWorker)(QIOTask *task,
|
|||||||
* 'err' attribute in the task object to determine if
|
* 'err' attribute in the task object to determine if
|
||||||
* the operation was successful or not.
|
* the operation was successful or not.
|
||||||
*
|
*
|
||||||
* The returned task will be released when one of
|
* The returned task will be released when qio_task_complete()
|
||||||
* qio_task_abort() or qio_task_complete() are invoked.
|
* is invoked.
|
||||||
*
|
*
|
||||||
* Returns: the task struct
|
* Returns: the task struct
|
||||||
*/
|
*/
|
||||||
@ -204,10 +231,8 @@ QIOTask *qio_task_new(Object *source,
|
|||||||
* @opaque: opaque data to pass to @worker
|
* @opaque: opaque data to pass to @worker
|
||||||
* @destroy: function to free @opaque
|
* @destroy: function to free @opaque
|
||||||
*
|
*
|
||||||
* Run a task in a background thread. If @worker
|
* Run a task in a background thread. When @worker
|
||||||
* returns 0 it will call qio_task_complete() in
|
* returns it will call qio_task_complete() in
|
||||||
* the main event thread context. If @worker
|
|
||||||
* returns -1 it will call qio_task_abort() in
|
|
||||||
* the main event thread context.
|
* the main event thread context.
|
||||||
*/
|
*/
|
||||||
void qio_task_run_in_thread(QIOTask *task,
|
void qio_task_run_in_thread(QIOTask *task,
|
||||||
@ -219,25 +244,11 @@ void qio_task_run_in_thread(QIOTask *task,
|
|||||||
* qio_task_complete:
|
* qio_task_complete:
|
||||||
* @task: the task struct
|
* @task: the task struct
|
||||||
*
|
*
|
||||||
* Mark the operation as successfully completed
|
* Invoke the completion callback for @task and
|
||||||
* and free the memory for @task.
|
* then free its memory.
|
||||||
*/
|
*/
|
||||||
void qio_task_complete(QIOTask *task);
|
void qio_task_complete(QIOTask *task);
|
||||||
|
|
||||||
/**
|
|
||||||
* qio_task_abort:
|
|
||||||
* @task: the task struct
|
|
||||||
* @err: the error to record for the operation
|
|
||||||
*
|
|
||||||
* Mark the operation as failed, with @err providing
|
|
||||||
* details about the failure. The @err may be freed
|
|
||||||
* afer the function returns, as the notification
|
|
||||||
* callback is invoked synchronously. The @task will
|
|
||||||
* be freed when this call completes.
|
|
||||||
*/
|
|
||||||
void qio_task_abort(QIOTask *task,
|
|
||||||
Error *err);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* qio_task_set_error:
|
* qio_task_set_error:
|
||||||
|
@ -153,8 +153,9 @@ static void qio_channel_tls_handshake_task(QIOChannelTLS *ioc,
|
|||||||
|
|
||||||
if (qcrypto_tls_session_handshake(ioc->session, &err) < 0) {
|
if (qcrypto_tls_session_handshake(ioc->session, &err) < 0) {
|
||||||
trace_qio_channel_tls_handshake_fail(ioc);
|
trace_qio_channel_tls_handshake_fail(ioc);
|
||||||
qio_task_abort(task, err);
|
qio_task_set_error(task, err);
|
||||||
goto cleanup;
|
qio_task_complete(task);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = qcrypto_tls_session_get_handshake_status(ioc->session);
|
status = qcrypto_tls_session_get_handshake_status(ioc->session);
|
||||||
@ -163,10 +164,10 @@ static void qio_channel_tls_handshake_task(QIOChannelTLS *ioc,
|
|||||||
if (qcrypto_tls_session_check_credentials(ioc->session,
|
if (qcrypto_tls_session_check_credentials(ioc->session,
|
||||||
&err) < 0) {
|
&err) < 0) {
|
||||||
trace_qio_channel_tls_credentials_deny(ioc);
|
trace_qio_channel_tls_credentials_deny(ioc);
|
||||||
qio_task_abort(task, err);
|
qio_task_set_error(task, err);
|
||||||
goto cleanup;
|
} else {
|
||||||
|
trace_qio_channel_tls_credentials_allow(ioc);
|
||||||
}
|
}
|
||||||
trace_qio_channel_tls_credentials_allow(ioc);
|
|
||||||
qio_task_complete(task);
|
qio_task_complete(task);
|
||||||
} else {
|
} else {
|
||||||
GIOCondition condition;
|
GIOCondition condition;
|
||||||
@ -183,9 +184,6 @@ static void qio_channel_tls_handshake_task(QIOChannelTLS *ioc,
|
|||||||
task,
|
task,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
|
||||||
error_free(err);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -279,8 +279,8 @@ static gboolean qio_channel_websock_handshake_send(QIOChannel *ioc,
|
|||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
trace_qio_channel_websock_handshake_fail(ioc);
|
trace_qio_channel_websock_handshake_fail(ioc);
|
||||||
qio_task_abort(task, err);
|
qio_task_set_error(task, err);
|
||||||
error_free(err);
|
qio_task_complete(task);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -307,8 +307,8 @@ static gboolean qio_channel_websock_handshake_io(QIOChannel *ioc,
|
|||||||
ret = qio_channel_websock_handshake_read(wioc, &err);
|
ret = qio_channel_websock_handshake_read(wioc, &err);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
trace_qio_channel_websock_handshake_fail(ioc);
|
trace_qio_channel_websock_handshake_fail(ioc);
|
||||||
qio_task_abort(task, err);
|
qio_task_set_error(task, err);
|
||||||
error_free(err);
|
qio_task_complete(task);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
|
18
io/task.c
18
io/task.c
@ -87,13 +87,11 @@ static gboolean gio_task_thread_result(gpointer opaque)
|
|||||||
struct QIOTaskThreadData *data = opaque;
|
struct QIOTaskThreadData *data = opaque;
|
||||||
|
|
||||||
trace_qio_task_thread_result(data->task);
|
trace_qio_task_thread_result(data->task);
|
||||||
if (data->ret == 0) {
|
if (data->err) {
|
||||||
qio_task_complete(data->task);
|
qio_task_set_error(data->task, data->err);
|
||||||
} else {
|
|
||||||
qio_task_abort(data->task, data->err);
|
|
||||||
}
|
}
|
||||||
|
qio_task_complete(data->task);
|
||||||
|
|
||||||
error_free(data->err);
|
|
||||||
if (data->destroy) {
|
if (data->destroy) {
|
||||||
data->destroy(data->opaque);
|
data->destroy(data->opaque);
|
||||||
}
|
}
|
||||||
@ -149,19 +147,11 @@ void qio_task_run_in_thread(QIOTask *task,
|
|||||||
|
|
||||||
void qio_task_complete(QIOTask *task)
|
void qio_task_complete(QIOTask *task)
|
||||||
{
|
{
|
||||||
task->func(task->source, NULL, task->opaque);
|
task->func(task, task->opaque);
|
||||||
trace_qio_task_complete(task);
|
trace_qio_task_complete(task);
|
||||||
qio_task_free(task);
|
qio_task_free(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
void qio_task_abort(QIOTask *task,
|
|
||||||
Error *err)
|
|
||||||
{
|
|
||||||
task->func(task->source, err, task->opaque);
|
|
||||||
trace_qio_task_abort(task);
|
|
||||||
qio_task_free(task);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void qio_task_set_error(QIOTask *task,
|
void qio_task_set_error(QIOTask *task,
|
||||||
Error *err)
|
Error *err)
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
# io/task.c
|
# io/task.c
|
||||||
qio_task_new(void *task, void *source, void *func, void *opaque) "Task new task=%p source=%p func=%p opaque=%p"
|
qio_task_new(void *task, void *source, void *func, void *opaque) "Task new task=%p source=%p func=%p opaque=%p"
|
||||||
qio_task_complete(void *task) "Task complete task=%p"
|
qio_task_complete(void *task) "Task complete task=%p"
|
||||||
qio_task_abort(void *task) "Task abort task=%p"
|
|
||||||
qio_task_thread_start(void *task, void *worker, void *opaque) "Task thread start task=%p worker=%p opaque=%p"
|
qio_task_thread_start(void *task, void *worker, void *opaque) "Task thread start task=%p worker=%p opaque=%p"
|
||||||
qio_task_thread_run(void *task) "Task thread run task=%p"
|
qio_task_thread_run(void *task) "Task thread run task=%p"
|
||||||
qio_task_thread_exit(void *task) "Task thread exit task=%p"
|
qio_task_thread_exit(void *task) "Task thread exit task=%p"
|
||||||
|
@ -70,22 +70,23 @@ static void socket_connect_data_free(void *opaque)
|
|||||||
g_free(data);
|
g_free(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void socket_outgoing_migration(Object *src,
|
static void socket_outgoing_migration(QIOTask *task,
|
||||||
Error *err,
|
|
||||||
gpointer opaque)
|
gpointer opaque)
|
||||||
{
|
{
|
||||||
struct SocketConnectData *data = opaque;
|
struct SocketConnectData *data = opaque;
|
||||||
QIOChannel *sioc = QIO_CHANNEL(src);
|
QIOChannel *sioc = QIO_CHANNEL(qio_task_get_source(task));
|
||||||
|
Error *err = NULL;
|
||||||
|
|
||||||
if (err) {
|
if (qio_task_propagate_error(task, &err)) {
|
||||||
trace_migration_socket_outgoing_error(error_get_pretty(err));
|
trace_migration_socket_outgoing_error(error_get_pretty(err));
|
||||||
data->s->to_dst_file = NULL;
|
data->s->to_dst_file = NULL;
|
||||||
migrate_fd_error(data->s, err);
|
migrate_fd_error(data->s, err);
|
||||||
|
error_free(err);
|
||||||
} else {
|
} else {
|
||||||
trace_migration_socket_outgoing_connected(data->hostname);
|
trace_migration_socket_outgoing_connected(data->hostname);
|
||||||
migration_channel_connect(data->s, sioc, data->hostname);
|
migration_channel_connect(data->s, sioc, data->hostname);
|
||||||
}
|
}
|
||||||
object_unref(src);
|
object_unref(OBJECT(sioc));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void socket_start_outgoing_migration(MigrationState *s,
|
static void socket_start_outgoing_migration(MigrationState *s,
|
||||||
|
@ -61,15 +61,15 @@ migration_tls_get_creds(MigrationState *s,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void migration_tls_incoming_handshake(Object *src,
|
static void migration_tls_incoming_handshake(QIOTask *task,
|
||||||
Error *err,
|
|
||||||
gpointer opaque)
|
gpointer opaque)
|
||||||
{
|
{
|
||||||
QIOChannel *ioc = QIO_CHANNEL(src);
|
QIOChannel *ioc = QIO_CHANNEL(qio_task_get_source(task));
|
||||||
|
Error *err = NULL;
|
||||||
|
|
||||||
if (err) {
|
if (qio_task_propagate_error(task, &err)) {
|
||||||
trace_migration_tls_incoming_handshake_error(error_get_pretty(err));
|
trace_migration_tls_incoming_handshake_error(error_get_pretty(err));
|
||||||
error_report("%s", error_get_pretty(err));
|
error_report_err(err);
|
||||||
} else {
|
} else {
|
||||||
trace_migration_tls_incoming_handshake_complete();
|
trace_migration_tls_incoming_handshake_complete();
|
||||||
migration_channel_process_incoming(migrate_get_current(), ioc);
|
migration_channel_process_incoming(migrate_get_current(), ioc);
|
||||||
@ -107,17 +107,18 @@ void migration_tls_channel_process_incoming(MigrationState *s,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void migration_tls_outgoing_handshake(Object *src,
|
static void migration_tls_outgoing_handshake(QIOTask *task,
|
||||||
Error *err,
|
|
||||||
gpointer opaque)
|
gpointer opaque)
|
||||||
{
|
{
|
||||||
MigrationState *s = opaque;
|
MigrationState *s = opaque;
|
||||||
QIOChannel *ioc = QIO_CHANNEL(src);
|
QIOChannel *ioc = QIO_CHANNEL(qio_task_get_source(task));
|
||||||
|
Error *err = NULL;
|
||||||
|
|
||||||
if (err) {
|
if (qio_task_propagate_error(task, &err)) {
|
||||||
trace_migration_tls_outgoing_handshake_error(error_get_pretty(err));
|
trace_migration_tls_outgoing_handshake_error(error_get_pretty(err));
|
||||||
s->to_dst_file = NULL;
|
s->to_dst_file = NULL;
|
||||||
migrate_fd_error(s, err);
|
migrate_fd_error(s, err);
|
||||||
|
error_free(err);
|
||||||
} else {
|
} else {
|
||||||
trace_migration_tls_outgoing_handshake_complete();
|
trace_migration_tls_outgoing_handshake_complete();
|
||||||
migration_channel_connect(s, ioc, NULL);
|
migration_channel_connect(s, ioc, NULL);
|
||||||
|
@ -78,15 +78,13 @@ ssize_t nbd_wr_syncv(QIOChannel *ioc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void nbd_tls_handshake(Object *src,
|
void nbd_tls_handshake(QIOTask *task,
|
||||||
Error *err,
|
|
||||||
void *opaque)
|
void *opaque)
|
||||||
{
|
{
|
||||||
struct NBDTLSHandshakeData *data = opaque;
|
struct NBDTLSHandshakeData *data = opaque;
|
||||||
|
|
||||||
if (err) {
|
if (qio_task_propagate_error(task, &data->error)) {
|
||||||
TRACE("TLS failed %s", error_get_pretty(err));
|
TRACE("TLS failed %s", error_get_pretty(data->error));
|
||||||
data->error = error_copy(err);
|
|
||||||
}
|
}
|
||||||
data->complete = true;
|
data->complete = true;
|
||||||
g_main_loop_quit(data->loop);
|
g_main_loop_quit(data->loop);
|
||||||
|
@ -120,8 +120,7 @@ struct NBDTLSHandshakeData {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void nbd_tls_handshake(Object *src,
|
void nbd_tls_handshake(QIOTask *task,
|
||||||
Error *err,
|
|
||||||
void *opaque);
|
void *opaque);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
18
qemu-char.c
18
qemu-char.c
@ -3277,14 +3277,13 @@ static void tcp_chr_telnet_init(CharDriverState *chr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void tcp_chr_tls_handshake(Object *source,
|
static void tcp_chr_tls_handshake(QIOTask *task,
|
||||||
Error *err,
|
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
CharDriverState *chr = user_data;
|
CharDriverState *chr = user_data;
|
||||||
TCPCharDriver *s = chr->opaque;
|
TCPCharDriver *s = chr->opaque;
|
||||||
|
|
||||||
if (err) {
|
if (qio_task_propagate_error(task, NULL)) {
|
||||||
tcp_chr_disconnect(chr);
|
tcp_chr_disconnect(chr);
|
||||||
} else {
|
} else {
|
||||||
if (s->do_telnetopt) {
|
if (s->do_telnetopt) {
|
||||||
@ -3492,20 +3491,23 @@ static void tcp_chr_free(CharDriverState *chr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void qemu_chr_socket_connected(Object *src, Error *err, void *opaque)
|
static void qemu_chr_socket_connected(QIOTask *task, void *opaque)
|
||||||
{
|
{
|
||||||
QIOChannelSocket *sioc = QIO_CHANNEL_SOCKET(src);
|
QIOChannelSocket *sioc = QIO_CHANNEL_SOCKET(qio_task_get_source(task));
|
||||||
CharDriverState *chr = opaque;
|
CharDriverState *chr = opaque;
|
||||||
TCPCharDriver *s = chr->opaque;
|
TCPCharDriver *s = chr->opaque;
|
||||||
|
Error *err = NULL;
|
||||||
|
|
||||||
if (err) {
|
if (qio_task_propagate_error(task, &err)) {
|
||||||
check_report_connect_error(chr, err);
|
check_report_connect_error(chr, err);
|
||||||
object_unref(src);
|
error_free(err);
|
||||||
return;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
s->connect_err_reported = false;
|
s->connect_err_reported = false;
|
||||||
tcp_chr_new_client(chr, sioc);
|
tcp_chr_new_client(chr, sioc);
|
||||||
|
|
||||||
|
cleanup:
|
||||||
object_unref(OBJECT(sioc));
|
object_unref(OBJECT(sioc));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,12 +156,11 @@ struct TestIOChannelData {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static void test_io_channel_complete(Object *src,
|
static void test_io_channel_complete(QIOTask *task,
|
||||||
Error *err,
|
|
||||||
gpointer opaque)
|
gpointer opaque)
|
||||||
{
|
{
|
||||||
struct TestIOChannelData *data = opaque;
|
struct TestIOChannelData *data = opaque;
|
||||||
data->err = err != NULL;
|
data->err = qio_task_propagate_error(task, NULL);
|
||||||
g_main_loop_quit(data->loop);
|
g_main_loop_quit(data->loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,14 +53,13 @@ struct QIOChannelTLSHandshakeData {
|
|||||||
bool failed;
|
bool failed;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void test_tls_handshake_done(Object *source,
|
static void test_tls_handshake_done(QIOTask *task,
|
||||||
Error *err,
|
|
||||||
gpointer opaque)
|
gpointer opaque)
|
||||||
{
|
{
|
||||||
struct QIOChannelTLSHandshakeData *data = opaque;
|
struct QIOChannelTLSHandshakeData *data = opaque;
|
||||||
|
|
||||||
data->finished = true;
|
data->finished = true;
|
||||||
data->failed = err != NULL;
|
data->failed = qio_task_propagate_error(task, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -50,14 +50,13 @@ struct TestTaskData {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static void task_callback(Object *source,
|
static void task_callback(QIOTask *task,
|
||||||
Error *err,
|
|
||||||
gpointer opaque)
|
gpointer opaque)
|
||||||
{
|
{
|
||||||
struct TestTaskData *data = opaque;
|
struct TestTaskData *data = opaque;
|
||||||
|
|
||||||
data->source = source;
|
data->source = qio_task_get_source(task);
|
||||||
data->err = err;
|
qio_task_propagate_error(task, &data->err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -120,9 +119,9 @@ static void test_task_failure(void)
|
|||||||
|
|
||||||
error_setg(&err, "Some error");
|
error_setg(&err, "Some error");
|
||||||
|
|
||||||
qio_task_abort(task, err);
|
qio_task_set_error(task, err);
|
||||||
|
qio_task_complete(task);
|
||||||
|
|
||||||
error_free(err);
|
|
||||||
object_unref(obj);
|
object_unref(obj);
|
||||||
|
|
||||||
g_assert(data.source == obj);
|
g_assert(data.source == obj);
|
||||||
@ -158,14 +157,13 @@ static int test_task_thread_worker(QIOTask *task,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void test_task_thread_callback(Object *source,
|
static void test_task_thread_callback(QIOTask *task,
|
||||||
Error *err,
|
|
||||||
gpointer opaque)
|
gpointer opaque)
|
||||||
{
|
{
|
||||||
struct TestThreadWorkerData *data = opaque;
|
struct TestThreadWorkerData *data = opaque;
|
||||||
|
|
||||||
data->source = source;
|
data->source = qio_task_get_source(task);
|
||||||
data->err = err;
|
qio_task_propagate_error(task, &data->err);
|
||||||
|
|
||||||
data->complete = g_thread_self();
|
data->complete = g_thread_self();
|
||||||
|
|
||||||
|
@ -65,16 +65,17 @@ static void start_auth_vencrypt_subauth(VncState *vs)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vnc_tls_handshake_done(Object *source,
|
static void vnc_tls_handshake_done(QIOTask *task,
|
||||||
Error *err,
|
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
VncState *vs = user_data;
|
VncState *vs = user_data;
|
||||||
|
Error *err = NULL;
|
||||||
|
|
||||||
if (err) {
|
if (qio_task_propagate_error(task, &err)) {
|
||||||
VNC_DEBUG("Handshake failed %s\n",
|
VNC_DEBUG("Handshake failed %s\n",
|
||||||
error_get_pretty(err));
|
error_get_pretty(err));
|
||||||
vnc_client_error(vs);
|
vnc_client_error(vs);
|
||||||
|
error_free(err);
|
||||||
} else {
|
} else {
|
||||||
vs->ioc_tag = qio_channel_add_watch(
|
vs->ioc_tag = qio_channel_add_watch(
|
||||||
vs->ioc, G_IO_IN | G_IO_OUT, vnc_client_io, vs, NULL);
|
vs->ioc, G_IO_IN | G_IO_OUT, vnc_client_io, vs, NULL);
|
||||||
|
14
ui/vnc-ws.c
14
ui/vnc-ws.c
@ -24,15 +24,16 @@
|
|||||||
#include "io/channel-websock.h"
|
#include "io/channel-websock.h"
|
||||||
#include "qemu/bswap.h"
|
#include "qemu/bswap.h"
|
||||||
|
|
||||||
static void vncws_tls_handshake_done(Object *source,
|
static void vncws_tls_handshake_done(QIOTask *task,
|
||||||
Error *err,
|
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
VncState *vs = user_data;
|
VncState *vs = user_data;
|
||||||
|
Error *err = NULL;
|
||||||
|
|
||||||
if (err) {
|
if (qio_task_propagate_error(task, &err)) {
|
||||||
VNC_DEBUG("Handshake failed %s\n", error_get_pretty(err));
|
VNC_DEBUG("Handshake failed %s\n", error_get_pretty(err));
|
||||||
vnc_client_error(vs);
|
vnc_client_error(vs);
|
||||||
|
error_free(err);
|
||||||
} else {
|
} else {
|
||||||
VNC_DEBUG("TLS handshake complete, starting websocket handshake\n");
|
VNC_DEBUG("TLS handshake complete, starting websocket handshake\n");
|
||||||
vs->ioc_tag = qio_channel_add_watch(
|
vs->ioc_tag = qio_channel_add_watch(
|
||||||
@ -83,15 +84,16 @@ gboolean vncws_tls_handshake_io(QIOChannel *ioc G_GNUC_UNUSED,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void vncws_handshake_done(Object *source,
|
static void vncws_handshake_done(QIOTask *task,
|
||||||
Error *err,
|
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
VncState *vs = user_data;
|
VncState *vs = user_data;
|
||||||
|
Error *err = NULL;
|
||||||
|
|
||||||
if (err) {
|
if (qio_task_propagate_error(task, &err)) {
|
||||||
VNC_DEBUG("Websock handshake failed %s\n", error_get_pretty(err));
|
VNC_DEBUG("Websock handshake failed %s\n", error_get_pretty(err));
|
||||||
vnc_client_error(vs);
|
vnc_client_error(vs);
|
||||||
|
error_free(err);
|
||||||
} else {
|
} else {
|
||||||
VNC_DEBUG("Websock handshake complete, starting VNC protocol\n");
|
VNC_DEBUG("Websock handshake complete, starting VNC protocol\n");
|
||||||
vnc_start_protocol(vs);
|
vnc_start_protocol(vs);
|
||||||
|
Loading…
Reference in New Issue
Block a user