[PATCH 2/2] libmbim-glib: mbim-device: Decouple logic for cancellable from timeout when storing transaction

Greg Suarez gpsuarez2512 at gmail.com
Wed Feb 5 11:12:28 PST 2014


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 at gmail.com>
---
 src/libmbim-glib/mbim-device.c | 24 ++++++++++++------------
 1 file 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;
         }
     }
 
-- 
1.8.5.3



More information about the libmbim-devel mailing list