Reset instance pid when widget app is aborted 00/146800/4
authorSemun Lee <semun.lee@samsung.com>
Wed, 30 Aug 2017 12:44:48 +0000 (21:44 +0900)
committerSemun Lee <semun.lee@samsung.com>
Thu, 31 Aug 2017 06:50:58 +0000 (15:50 +0900)
When widget instance is aborted while creating,
pid needs to be reset. When pid is reset by the framework,
lifecycle event needs to be handled even when the pid of
event sender is not matched.

Change-Id: Ic51e9c86485d630d377759d3e8e5d1445e614517
Signed-off-by: Semun Lee <semun.lee@samsung.com>
src/widget_instance.c

index 41b4a72..a46551b 100644 (file)
@@ -557,7 +557,7 @@ EAPI int widget_instance_destroy(const char *instance_id)
                return -1;
        }
 
-       if (instance->pid) {
+       if (instance->pid > 0) {
                ret = __send_aul_cmd(instance, "destroy", NULL);
        } else { /* uninitialized */
                __remove_instance(instance);
@@ -686,8 +686,9 @@ static int __check_valid_sender(char *widget_id, int pid)
                head = app->instances;
                if (head) {
                        instance = (widget_instance_h)head->data;
-                       if (instance->pid == pid)
+                       if (instance->pid == -1 || instance->pid == pid)
                                return 0;
+                       _E("instance->pid (%d), pid (%d)", instance->pid, pid);
                }
        }
        return -1;
@@ -835,7 +836,9 @@ static int __widget_instance_handler(int status, char *widget_id, char *instance
                }
                break;
        case WIDGET_INSTANCE_EVENT_FAULT:
-
+               break;
+       case WIDGET_INSTANCE_EVENT_CREATE_ABORTED:
+               instance->pid = -1;
                break;
        default:
                _E("unknown status: %d", status);
@@ -896,7 +899,7 @@ static int __fault_handler(int pid)
        while (iter) {
                instance = (struct _widget_instance *)iter->data;
                if (instance && instance->pid == pid) {
-                       instance->pid = 0;
+                       instance->pid = -1;
                        instance->status = WIDGET_INSTANCE_TERMINATED;
                        __notify_event(WIDGET_INSTANCE_EVENT_FAULT, instance->widget_id, instance->id);
                }