AT: Free request when sync failed, consider failed for reason status sill going
authorPaul Kocialkowski <contact@paulk.fr>
Tue, 31 Jul 2012 19:43:11 +0000 (21:43 +0200)
committerPaul Kocialkowski <contact@paulk.fr>
Tue, 31 Jul 2012 19:43:11 +0000 (21:43 +0200)
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
at.c

diff --git a/at.c b/at.c
index 7763ce8..541766c 100644 (file)
--- a/at.c
+++ b/at.c
@@ -1519,6 +1519,9 @@ int at_sync_response_dequeue(struct at_response *response)
                // FIXME: What if we get some data for the sync request here, but not with the status yet => set response already => next time if there is already a response, grab its data
 
                sync_request = at_sync_request_find_handled(AT_RESPONSE_SENT);
+               if(sync_request == NULL)
+                       sync_request = at_sync_request_find_handled(AT_RESPONSE_UNHANDELD_REASON_STATUS);
+
                if(sync_request != NULL && sync_request->command != NULL) {
                        // If we catch an unsol or a response for another request, there is something wrong
 
@@ -1925,8 +1928,10 @@ struct at_response *at_send_sync(char *command, char *data)
        }
 
        response = at_request_send_sync(request);
-
-       at_request_free(request);
+       if(response == NULL) {
+               at_request_free(request);
+               return NULL;
+       }
 
        return response;
 }
@@ -1945,7 +1950,6 @@ int at_send_expect_to_func(char *command, char *data, void *async_data, RIL_Toke
        rc = at_request_send_async(request, async_data, token, func);
        if(rc < 0) {
                LOGE("Unable to send async request, aborting");
-
                at_request_free(request);
                return -1;
        }