mot-agent: fix crash when timeout callback and thread call
authorsaerome.kim <saerome.kim@samsung.com>
Thu, 25 Jan 2018 07:42:04 +0000 (16:42 +0900)
committersaerome.kim <saerome.kim@samsung.com>
Mon, 2 Jul 2018 10:38:47 +0000 (19:38 +0900)
_request_cleanup() simulatenously.

Signed-off-by: saerome.kim <saerome.kim@samsung.com>
src/mot-agent/ma-subowner.c

index 9362c916933907918b29374c2f0f6a8487eabbdf..fbb8dfd9f08465a717ee4a7dca74310c973c1707 100644 (file)
@@ -62,7 +62,7 @@
 #define CALLBACK_TIMEOUT_10S 10 * 1000 /**< 10 sec = 10 * 1000 * 1ms */
 #define CALLBACK_TIMEOUT_5S 5 * 1000 /**< 5sec = 5 * 1000 * 1ms */
 
-#define TIMEOUT_USED
+//#define TIMEOUT_USED
 #define DEBUG_UUID
 
 /* '_' for separaing from the same constant variable in srmresourcestrings.c  */
@@ -532,11 +532,6 @@ static void _request_cleanup(gpointer data)
        ma_service *service = (ma_service *)con->userdata;
        ma_check_null_ret("service", service);
 
-       if (!con) {
-               MA_LOGI("container is null");
-               return;
-       }
-
        if (con->tid) {
                g_source_remove(con->tid);
                con->tid = 0;
@@ -717,7 +712,9 @@ static gboolean _ma_timeout_cb(gpointer data)
                return G_SOURCE_REMOVE;
        }
 
-       OCPDMCleanupForTimeout();
+       if (MA_DISC_MOWNED_DEVS < con->cid) {
+               OCPDMCleanupForTimeout();
+       }
 
        switch (con->cid) {
        case MA_DISC_MOT_ENB_DEVS:
@@ -757,7 +754,7 @@ static gboolean _ma_timeout_cb(gpointer data)
                break;
        }
 
-       _request_cleanup((gpointer)con);
+       _request_cleanup(con);
 
        return G_SOURCE_REMOVE;
 }
@@ -777,7 +774,9 @@ static gpointer _disc_mot_env_devs_func(gpointer data)
        __notify_found_devs(con);
 
 DISC_MOT_ENB_DEVS_END:
+
        _request_cleanup(con);
+
        g_thread_exit(GINT_TO_POINTER (1));
 
        return NULL;