Send the PD destroyed event before handles registered callbacks. 02/12502/1
authorSung-jae Park <nicesj.park@samsung.com>
Sat, 16 Nov 2013 05:35:00 +0000 (14:35 +0900)
committerSung-jae Park <nicesj.park@samsung.com>
Sat, 16 Nov 2013 05:35:00 +0000 (14:35 +0900)
To guarantees the data validity of an instance.

Change-Id: I155dbf01c3a049a98c6bea2856d9c293846084b4

packaging/data-provider-master.spec
src/instance.c
src/server.c

index 39ef46c..2c6b9c3 100644 (file)
@@ -1,6 +1,6 @@
 Name: data-provider-master
 Summary: Master service provider for liveboxes
-Version: 0.25.25
+Version: 0.25.26
 Release: 1
 Group: HomeTF/Livebox
 License: Flora
index ab6669c..d3bd44d 100644 (file)
@@ -533,12 +533,19 @@ static int send_pd_destroyed_to_client(struct inst_info *inst, int status)
 {
        struct packet *packet;
 
+       if (!inst->pd.need_to_send_close_event) {
+               ErrPrint("PD is not created\n");
+               return LB_STATUS_ERROR_INVALID;
+       }
+
        packet = packet_create_noack("pd_destroyed", "ssi", package_name(inst->info), inst->id, status);
        if (!packet) {
                ErrPrint("Failed to create a packet\n");
                return LB_STATUS_ERROR_FAULT;
        }
 
+       inst->pd.need_to_send_close_event = 0;
+
        return CLIENT_SEND_EVENT(inst, packet);
 }
 
@@ -618,6 +625,8 @@ static inline void destroy_instance(struct inst_info *inst)
        struct event_item *item;
        struct tag_item *tag_item;
 
+       (void)send_pd_destroyed_to_client(inst, LB_STATUS_SUCCESS);
+
        invoke_delete_callbacks(inst);
 
        pkg = inst->info;
@@ -628,10 +637,6 @@ static inline void destroy_instance(struct inst_info *inst)
 
        DbgPrint("Instance is destroyed (%p), slave(%p)\n", inst, slave);
 
-       if (inst->pd.need_to_send_close_event) {
-               send_pd_destroyed_to_client(inst, 0);
-       }
-
        if (lb_type == LB_TYPE_SCRIPT) {
                script_handler_unload(inst->lb.canvas.script, 0);
                script_handler_destroy(inst->lb.canvas.script);
@@ -3054,13 +3059,6 @@ HAPI int instance_client_pd_created(struct inst_info *inst, int status)
 
 HAPI int instance_client_pd_destroyed(struct inst_info *inst, int status)
 {
-       if (!inst->pd.need_to_send_close_event) {
-               ErrPrint("PD is not created\n");
-               return LB_STATUS_ERROR_INVALID;
-       }
-
-       inst->pd.need_to_send_close_event = 0;
-
        return send_pd_destroyed_to_client(inst, status);
 }
 
index 778bfe3..6b7730d 100644 (file)
@@ -4328,6 +4328,10 @@ static Eina_Bool lazy_pd_destroyed_cb(void *inst)
 
        if (instance_unref(inst)) {
                int ret;
+               
+               /*!
+                * If the instance is not deleted, we should send pd-destroy event from here.
+                */
                ret = instance_client_pd_destroyed(inst, LB_STATUS_SUCCESS);
                if (ret < 0) {
                        ErrPrint("Failed sending PD Destroy event (%d)\n", ret);