diff options
author | Greg Suarez <gpsuarez2512@gmail.com> | 2014-02-05 11:12:28 -0800 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2014-02-06 20:19:16 +0100 |
commit | 3e5ab128bcf286bf80af684414dee5c4c4add009 (patch) | |
tree | d3eae7fcfd71ce6e6af6976ba0ca2a168dc2f6d8 | |
parent | d7823dbaebfd62cfe3a34c83346be56236194284 (diff) | |
download | libmbim-3e5ab128bcf286bf80af684414dee5c4c4add009.tar.gz |
libmbim-glib: mbim-device: Decouple logic for cancellable from timeout when storing transaction
Decouple the logic for connecting a cancellable from adding a timeout.
Also check if the cancellable has been connected already.
Signed-off-by: Greg Suarez <gpsuarez2512@gmail.com>
-rw-r--r-- | src/libmbim-glib/mbim-device.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/libmbim-glib/mbim-device.c b/src/libmbim-glib/mbim-device.c index ef47b7e..6f965e9 100644 --- a/src/libmbim-glib/mbim-device.c +++ b/src/libmbim-glib/mbim-device.c @@ -272,19 +272,19 @@ device_store_transaction (MbimDevice *self, tr->timeout_id = g_timeout_add (timeout_ms, (GSourceFunc)transaction_timed_out, tr->wait_ctx); + } - if (tr->cancellable) { - tr->cancellable_id = g_cancellable_connect (tr->cancellable, - (GCallback)transaction_cancelled, - tr->wait_ctx, - NULL); - if (!tr->cancellable_id) { - g_set_error_literal (error, - MBIM_CORE_ERROR, - MBIM_CORE_ERROR_ABORTED, - "Request is already cancelled"); - return FALSE; - } + if (tr->cancellable && !tr->cancellable_id) { + tr->cancellable_id = g_cancellable_connect (tr->cancellable, + (GCallback)transaction_cancelled, + tr->wait_ctx, + NULL); + if (!tr->cancellable_id) { + g_set_error_literal (error, + MBIM_CORE_ERROR, + MBIM_CORE_ERROR_ABORTED, + "Request is already cancelled"); + return FALSE; } } |