AT: Corrected check async requests before canceling a sync request
authorPaul Kocialkowski <contact@paulk.fr>
Wed, 25 Jul 2012 22:45:01 +0000 (00:45 +0200)
committerPaul Kocialkowski <contact@paulk.fr>
Wed, 25 Jul 2012 22:45:01 +0000 (00:45 +0200)
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
at.c

diff --git a/at.c b/at.c
index 3b77b63..2c0605b 100644 (file)
--- a/at.c
+++ b/at.c
@@ -807,14 +807,18 @@ int at_response_expect_status(struct at_response *response)
        }
 
        if(response->status == AT_STATUS_UNDEF) {
-               // Only fail and clean if there is a status and command differs
+               // Only unlock if there is a status and command differs
                return -1;
        }
 
        if(response->command != NULL) {
                rc = at_commands_compare(response->command, at_responses_handling.sync_request->command);
                if(!rc) {
-                       AT_SYNC_UNLOCK();
+                       // Only unlock is there is no async request waiting with this command!
+                       if(at_request_expect_to_func_find(response->command) == NULL) {
+                               AT_SYNC_UNLOCK();
+                       }
+
                        return -1;
                }
        }
@@ -842,10 +846,7 @@ int at_expect_status(struct at_request *request)
        if(at_responses_handling.sync_response->command != NULL) {
                rc = at_commands_compare(at_responses_handling.sync_response->command, request->command);
                if(!rc) {
-                       // Only fail is there is no async request waiting with this command!
-                       if(at_request_expect_to_func_find(at_responses_handling.sync_response->command) != NULL)
-                               LOGE("Obtained command doesn't match, aborting!");
-
+                       LOGE("Obtained command doesn't match, aborting!");
                        return -1;
                }
        }