Fix when remove app event callback from list 36/105336/1 accepted/tizen_3.0.m2_mobile accepted/tizen_3.0.m2_tv accepted/tizen_3.0.m2_wearable tizen_3.0.m2 accepted/tizen/3.0.m2/mobile/20170104.100256 accepted/tizen/3.0.m2/tv/20170104.100429 accepted/tizen/3.0.m2/wearable/20170104.101032 accepted/tizen/3.0/common/20161219.113518 accepted/tizen/3.0/ivi/20161219.071339 accepted/tizen/3.0/tv/20161219.074014 accepted/tizen/3.0/wearable/20161219.095451 submit/tizen_3.0.m2/20170104.093748 submit/tizen_3.0/20161216.082724
authorJunghyun Yeon <jungh.yeon@samsung.com>
Fri, 16 Dec 2016 08:29:51 +0000 (17:29 +0900)
committerJunghyun Yeon <jungh.yeon@samsung.com>
Fri, 16 Dec 2016 08:29:51 +0000 (17:29 +0900)
- Consider when first callback has to be removed

Change-Id: I7beaa8871005203539256566e4aeccb801292ede
Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
src/app_manager_event.c

index fcdea81..a5dc931 100644 (file)
 
 #define LOG_TAG "CAPI_APPFW_APP_MANAGER"
 
-static int __remove_app_manager_event_info(app_manager_event_info *head, int req_id)
+static int __remove_app_manager_event_info(app_manager_event_info **head, int req_id)
 {
        app_manager_event_info *prev;
        app_manager_event_info *current;
 
-       current = prev = head;
+       current = prev = *head;
        if (current == NULL)
                return APP_MANAGER_ERROR_INVALID_PARAMETER;
 
        while (current) {
                if (current->req_id == req_id) {
+                       if (prev == current)
+                               *head = current->next;
                        prev->next = current->next;
                        free(current);
-                       current = NULL;
                        return APP_MANAGER_ERROR_NONE;
                }
                prev = current;
@@ -166,7 +167,7 @@ int app_event_handler(uid_t target_uid, int req_id,
                        app_evt->event_cb(pkg_type, appid, event_type,
                                        APP_MANAGER_EVENT_STATE_FAILED, app_evt, app_evt->user_data);
 
-               ret = __remove_app_manager_event_info(app_evt->head, req_id);
+               ret = __remove_app_manager_event_info(&(app_evt->head), req_id);
                if (ret != APP_MANAGER_ERROR_NONE) {
                        LOGE("failed to remove app event info");
                        return APP_MANAGER_ERROR_REQUEST_FAILED;