Fix calling result callback 15/34015/1
authorSangyoon Jang <s89.jang@samsung.com>
Tue, 20 Jan 2015 01:38:22 +0000 (10:38 +0900)
committerSangyoon Jang <s89.jang@samsung.com>
Tue, 20 Jan 2015 01:45:07 +0000 (10:45 +0900)
when adding callback, it prepends the list
but when finding callback, the first matching callback is called (LIFO)
it should be FIFO

Change-Id: Ied1d71b13be6e572c259eea08d29e59200ddf7bd
Signed-off-by: Sangyoon Jang <s89.jang@samsung.com>
src/launch_with_result.c

index b8ff4fd..00e3c7c 100644 (file)
@@ -79,18 +79,18 @@ static void __add_resultcb(int pid, void (*cbfunc) (bundle *, int, void *),
 static app_resultcb_info_t *__find_resultcb(int pid)
 {
        app_resultcb_info_t *tmp;
+       app_resultcb_info_t *ret = NULL;
 
        pthread_mutex_lock(&result_lock);
        tmp = rescb_head;
        while (tmp) {
-               if (tmp->launched_pid == pid) {
-                       pthread_mutex_unlock(&result_lock);
-                       return tmp;
-               }
+               if (tmp->launched_pid == pid)
+                       ret = tmp;
                tmp = tmp->next;
        }
        pthread_mutex_unlock(&result_lock);
-       return NULL;
+
+       return ret;
 }
 
 static void __remove_resultcb(app_resultcb_info_t *info)