fix crash for testhub issue on wearable 66/145266/1
authorjomui <jongmun.woo@samsung.com>
Tue, 22 Aug 2017 02:23:52 +0000 (11:23 +0900)
committerjomui <jongmun.woo@samsung.com>
Tue, 22 Aug 2017 02:24:05 +0000 (11:24 +0900)
Signed-off-by: jomui <jongmun.woo@samsung.com>
Change-Id: I59582b08606b408d72bde003888b1f2a893463e5

src/mapzen/mapzen_queue.c

index 38c9b31..87c1f08 100644 (file)
@@ -29,6 +29,7 @@ pthread_mutex_t __requestLock;
 static GAsyncQueue *responseQueue = NULL;
 int __ResponseQueueLen = 0;
 bool __response_timer_running = false;
+guint __timeout_id = 0;
 
 /* Request List */
 GList *requestList = NULL;
@@ -1050,6 +1051,7 @@ static gboolean __timeout_cb(gpointer data)
        g_async_queue_unref(responseQueue);
 
        __response_timer_running = false;
+       __timeout_id = 0;
 
        return false;
 }
@@ -1503,6 +1505,10 @@ int mapzen_init_queue()
 int mapzen_deinit_queue()
 {
        deinit_curl();
+       if (__timeout_id != 0) {
+               g_source_remove (__timeout_id);
+               __timeout_id = 0;
+       }
 
        g_list_free(reqCancelList);
        reqCancelList = NULL;
@@ -1625,7 +1631,7 @@ int mapzen_push_to_queue(mapzen_resp_type type, gpointer data)
 
        if (!__response_timer_running) {
                MAP_DEBUG(">>>>>>>>>>>>>>>>>>>>>>> TRIGGER RESPONSE TIMER <<<<<<<<<<<<<<<<<<<<<<<<<");
-               g_timeout_add_seconds(1, __timeout_cb, NULL);   /* timeout : 1 sec */
+               __timeout_id = g_timeout_add_seconds(1, __timeout_cb, NULL);    /* timeout : 1 sec */
        } else {
                __ResponseQueueLen = g_async_queue_length(responseQueue);
                MAP_DEBUG(">>>>>>>>>>>>>>>>>> Timer already running. Response Queue Len [%d] <<<<<<<<<<<<<<<<<", __ResponseQueueLen);