summaryrefslogtreecommitdiffstats
path: root/src/usb-acl-helper.c
diff options
context:
space:
mode:
authorFabiano Fidêncio <fidencio@redhat.com>2016-03-23 03:50:40 +0100
committerFabiano Fidêncio <fidencio@redhat.com>2016-03-23 04:22:37 +0100
commit0fa5895d6218269cce31315c36cb588c72a52fe0 (patch)
treec814ae20419b8c9715c93971d1a69f84aa0837eb /src/usb-acl-helper.c
parentf973df7e54b296f5cd2eca7498aea285a84ab007 (diff)
downloadspice-gtk-0fa5895d6218269cce31315c36cb588c72a52fe0.tar.gz
spice-gtk-0fa5895d6218269cce31315c36cb588c72a52fe0.tar.xz
spice-gtk-0fa5895d6218269cce31315c36cb588c72a52fe0.zip
Introduce gtask-helper.[ch]wip/gtask-helper
As noticed, GTask's heurestic for return a task in idle or immediately doesn't work when using Coroutine and that's okay, we just need to do the idle ourself. And in order to avoid code duplication, let's introduce and make usage of the new g_task_helper_return_* functions. These functions match exactly with the existing g_task_return_* functions and the only difference is that they return on idle instead of returning immediately. Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Diffstat (limited to 'src/usb-acl-helper.c')
-rw-r--r--src/usb-acl-helper.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/usb-acl-helper.c b/src/usb-acl-helper.c
index 487e1ee..231ac23 100644
--- a/src/usb-acl-helper.c
+++ b/src/usb-acl-helper.c
@@ -25,6 +25,8 @@
#include <stdio.h>
#include <string.h>
+#include "gtask-helper.h"
+
#include "usb-acl-helper.h"
/* ------------------------------------------------------------------ */
@@ -91,7 +93,7 @@ static void spice_usb_acl_helper_class_init(SpiceUsbAclHelperClass *klass)
static void async_result_set_cancelled(GTask *task)
{
- g_task_return_new_error(task,
+ g_task_helper_return_new_error(task,
G_IO_ERROR, G_IO_ERROR_CANCELLED,
"Setting USB device node ACL cancelled");
}
@@ -120,11 +122,11 @@ static gboolean cb_out_watch(GIOChannel *channel,
string[strlen(string) - 1] = 0;
if (!strcmp(string, "SUCCESS")) {
success = TRUE;
- g_task_return_boolean(priv->task, TRUE);
+ g_task_helper_return_boolean(priv->task, TRUE);
} else if (!strcmp(string, "CANCELED")) {
async_result_set_cancelled(priv->task);
} else {
- g_task_return_new_error(priv->task,
+ g_task_helper_return_new_error(priv->task,
SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
"Error setting USB device node ACL: '%s'",
string);
@@ -132,10 +134,10 @@ static gboolean cb_out_watch(GIOChannel *channel,
g_free(string);
break;
case G_IO_STATUS_ERROR:
- g_task_return_error(priv->task, err);
+ g_task_helper_return_error(priv->task, err);
break;
case G_IO_STATUS_EOF:
- g_task_return_new_error(priv->task,
+ g_task_helper_return_new_error(priv->task,
SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
"Unexpected EOF reading from acl helper stdout");
break;