Handling the exceptions for PD request correctly.
authorSung-jae Park <nicesj.park@samsung.com>
Sat, 29 Jun 2013 05:06:18 +0000 (14:06 +0900)
committerGerrit Code Review <gerrit@gerrit.vlan144.tizendev.org>
Mon, 1 Jul 2013 12:16:31 +0000 (12:16 +0000)
When the master gets time out for PD request.
It doesn't reset the PD,owner after delete it.
So the client cannot request a open the PD again.

Change-Id: Ice2742383fdc2713caa887292fed0fdb69d04e70

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

index 42c2bc3..409aed8 100644 (file)
@@ -221,7 +221,7 @@ extern int instance_client_pd_created(struct inst_info *inst, int status);
 extern int instance_send_access_status(struct inst_info *inst, int status);
 extern int instance_forward_packet(struct inst_info *inst, struct packet *packet);
 
-extern const struct client_node *instance_pd_owner(struct inst_info *inst);
+extern struct client_node *instance_pd_owner(struct inst_info *inst);
 
 /*!
  * Multiple viewer
index ccd46f7..0f03aaf 100644 (file)
@@ -1,6 +1,6 @@
 Name: data-provider-master
 Summary: Master service provider for liveboxes.
-Version: 0.24.13
+Version: 0.24.14
 Release: 1
 Group: HomeTF/Livebox
 License: Flora License
index 35dcd98..3db618c 100644 (file)
@@ -224,7 +224,6 @@ static inline struct buffer *create_pixmap(struct buffer_info *info)
                ErrPrint("Unable to clear the pixmap\n");
        }
 
-       DbgPrint("Pixmap:0x%X is created\n", gem->pixmap);
        return buffer;
 }
 
@@ -393,7 +392,7 @@ static inline int destroy_pixmap(struct buffer *buffer)
                if (!disp)
                        return LB_STATUS_ERROR_IO;
 
-               DbgPrint("pixmap 0x%X\n", gem->pixmap);
+               DbgPrint("pixmap %lu\n", gem->pixmap);
                XFreePixmap(disp, gem->pixmap);
        }
 
@@ -1056,7 +1055,7 @@ HAPI int buffer_handler_resize(struct buffer_info *info, int w, int h)
        buffer_handler_update_size(info, w, h);
 
        if (!info->is_loaded) {
-               DbgPrint("Not yet loaded\n");
+               DbgPrint("Buffer size is updated[%dx%d]\n", w, h);
                return LB_STATUS_SUCCESS;
        }
 
index bd77e00..ab63d8e 100644 (file)
@@ -2802,19 +2802,25 @@ HAPI int instance_slave_open_pd(struct inst_info *inst, struct client_node *clie
                }
        }
 
-       slave = package_slave(instance_package(inst));
-       if (!slave)
-               return LB_STATUS_ERROR_FAULT;
-
        info = instance_package(inst);
-       if (!info)
+       if (!info) {
+               ErrPrint("No package info\n");
                return LB_STATUS_ERROR_INVALID;
+       }
+
+       slave = package_slave(info);
+       if (!slave) {
+               ErrPrint("No slave\n");
+               return LB_STATUS_ERROR_FAULT;
+       }
 
        pkgname = package_name(info);
        id = instance_id(inst);
 
-       if (!pkgname || !id)
+       if (!pkgname || !id) {
+               ErrPrint("pkgname[%s] id[%s]\n", pkgname, id);
                return LB_STATUS_ERROR_INVALID;
+       }
 
        packet = packet_create_noack("pd_show", "ssiidd", pkgname, id, instance_pd_width(inst), instance_pd_height(inst), inst->pd.x, inst->pd.y);
        if (!packet) {
@@ -2871,32 +2877,43 @@ HAPI int instance_slave_close_pd(struct inst_info *inst, struct client_node *cli
        struct pkg_info *pkg;
        int ret;
 
-       if (inst->pd.owner != client)
-               return LB_STATUS_ERROR_INVALID;
-
-       slave = package_slave(instance_package(inst));
-       if (!slave)
-               return LB_STATUS_ERROR_FAULT;
+       if (inst->pd.owner != client) {
+               ErrPrint("Has no permission\n");
+               return LB_STATUS_ERROR_PERMISSION;
+       }
 
        pkg = instance_package(inst);
-       if (!pkg)
+       if (!pkg) {
+               ErrPrint("No package info\n");
                return LB_STATUS_ERROR_INVALID;
+       }
+
+       slave = package_slave(pkg);
+       if (!slave) {
+               ErrPrint("No assigned slave\n");
+               return LB_STATUS_ERROR_FAULT;
+       }
 
        pkgname = package_name(pkg);
        id = instance_id(inst);
 
-       if (!pkgname || !id)
+       if (!pkgname || !id) {
+               ErrPrint("pkgname[%s] & id[%s] is not valid\n", pkgname, id);
                return LB_STATUS_ERROR_INVALID;
+       }
 
        packet = packet_create_noack("pd_hide", "ss", pkgname, id);
-       if (!packet)
+       if (!packet) {
+               ErrPrint("Failed to create a packet\n");
                return LB_STATUS_ERROR_FAULT;
+       }
 
        slave_thaw_ttl(slave);
 
        ret = slave_rpc_request_only(slave, pkgname, packet, 0);
        release_resource_for_closing_pd(pkg, inst, client);
        inst->pd.owner = NULL;
+       DbgPrint("PERF_DBOX\n");
        return ret;
 }
 
@@ -3089,7 +3106,7 @@ HAPI void *instance_get_data(struct inst_info *inst, const char *tag)
        return item->data;
 }
 
-HAPI const struct client_node *instance_pd_owner(struct inst_info *inst)
+HAPI struct client_node *instance_pd_owner(struct inst_info *inst)
 {
        return inst->pd.owner;
 }
index 2e00ffe..5725aac 100644 (file)
@@ -4610,9 +4610,12 @@ out:
 static Eina_Bool pd_open_monitor_cb(void *data)
 {
        int ret;
-       ret = instance_client_pd_created(data, LB_STATUS_ERROR_TIMEOUT);
-       (void)instance_del_data(data, "pd,open,monitor");
-       (void)instance_unref(data);
+       struct inst_info *inst = data;
+
+       ret = instance_slave_close_pd(inst, instance_pd_owner(inst));
+       ret = instance_client_pd_created(inst, LB_STATUS_ERROR_TIMEOUT);
+       (void)instance_del_data(inst, "pd,open,monitor");
+       (void)instance_unref(inst);
        ErrPrint("PD Open request is timed-out (%lf), ret: %d\n", PD_REQUEST_TIMEOUT, ret);
        return ECORE_CALLBACK_CANCEL;
 }
@@ -4620,6 +4623,7 @@ static Eina_Bool pd_open_monitor_cb(void *data)
 static Eina_Bool pd_close_monitor_cb(void *data)
 {
        int ret;
+
        ret = instance_client_pd_destroyed(data, LB_STATUS_ERROR_TIMEOUT);
        (void)instance_del_data(data, "pd,close,monitor");
        (void)instance_unref(data);
@@ -4630,10 +4634,12 @@ static Eina_Bool pd_close_monitor_cb(void *data)
 static Eina_Bool pd_resize_monitor_cb(void *data)
 {
        int ret;
+       struct inst_info *inst = data;
 
-       ret = instance_client_pd_destroyed(data, LB_STATUS_ERROR_TIMEOUT);
-       (void)instance_del_data(data, "pd,resize,monitor");
-       (void)instance_unref(data);
+       ret = instance_slave_close_pd(inst, instance_pd_owner(inst));
+       ret = instance_client_pd_destroyed(inst, LB_STATUS_ERROR_TIMEOUT);
+       (void)instance_del_data(inst, "pd,resize,monitor");
+       (void)instance_unref(inst);
        ErrPrint("PD Resize request is not processed in %lf seconds (%d)\n", PD_REQUEST_TIMEOUT, ret);
        return ECORE_CALLBACK_CANCEL;
 }
@@ -4670,6 +4676,7 @@ static struct packet *client_create_pd(pid_t pid, int handle, const struct packe
                goto out;
 
        if (instance_pd_owner(inst)) {
+               ErrPrint("PD is already owned\n");
                ret = LB_STATUS_ERROR_ALREADY;
        } else if (package_pd_type(instance_package(inst)) == PD_TYPE_BUFFER) {
                lazy_pd_destroyed_cb(inst);
@@ -4830,6 +4837,8 @@ static struct packet *client_destroy_pd(pid_t pid, int handle, const struct pack
        const struct pkg_info *pkg;
        Ecore_Timer *pd_monitor;
 
+       DbgPrint("PERF_DBOX\n");
+
        client = client_find_by_pid(pid);
        if (!client) {
                ErrPrint("Client %d is not exists\n", pid);
@@ -4849,7 +4858,13 @@ static struct packet *client_destroy_pd(pid_t pid, int handle, const struct pack
                goto out;
 
        if (instance_pd_owner(inst) != client) {
-               ret = instance_pd_owner(inst) == NULL ? LB_STATUS_ERROR_ALREADY : LB_STATUS_ERROR_PERMISSION;
+               if (instance_pd_owner(inst) == NULL) {
+                       ErrPrint("PD looks already closed\n");
+                       ret = LB_STATUS_ERROR_ALREADY;
+               } else {
+                       ErrPrint("PD owner mimatched\n");
+                       ret = LB_STATUS_ERROR_PERMISSION;
+               }
        } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
                int resize_aborted = 0;
 
@@ -4911,23 +4926,21 @@ static struct packet *client_destroy_pd(pid_t pid, int handle, const struct pack
                ret = instance_slave_close_pd(inst, client);
                if (ret < 0) {
                        ErrPrint("PD close request failed: %d\n", ret);
+               } else if (resize_aborted) {
+                       pd_monitor = ecore_timer_add(DELAY_TIME, lazy_pd_destroyed_cb, instance_ref(inst));
+                       if (!pd_monitor) {
+                               ErrPrint("Failed to create a timer: %s\n", pkgname);
+                               (void)instance_unref(inst);
+                       } else {
+                               (void)instance_set_data(inst, "lazy,pd,close", pd_monitor);
+                       }
                } else {
-                       if (resize_aborted) {
-                               pd_monitor = ecore_timer_add(DELAY_TIME, lazy_pd_destroyed_cb, instance_ref(inst));
-                               if (!pd_monitor) {
-                                       ErrPrint("Failed to create a timer: %s\n", pkgname);
-                                       (void)instance_unref(inst);
-                               } else {
-                                       (void)instance_set_data(inst, "lazy,pd,close", pd_monitor);
-                               }
+                       pd_monitor = ecore_timer_add(PD_REQUEST_TIMEOUT, pd_close_monitor_cb, instance_ref(inst));
+                       if (!pd_monitor) {
+                               (void)instance_unref(inst);
+                               ErrPrint("Failed to add pd close monitor\n");
                        } else {
-                               pd_monitor = ecore_timer_add(PD_REQUEST_TIMEOUT, pd_close_monitor_cb, instance_ref(inst));
-                               if (!pd_monitor) {
-                                       (void)instance_unref(inst);
-                                       ErrPrint("Failed to add pd close monitor\n");
-                               } else {
-                                       (void)instance_set_data(inst, "pd,close,monitor", pd_monitor);
-                               }
+                               (void)instance_set_data(inst, "pd,close,monitor", pd_monitor);
                        }
                }
                /*!
@@ -6171,7 +6184,7 @@ static struct packet *slave_release_buffer(pid_t pid, int handle, const struct p
 
                pd_monitor = instance_del_data(inst, "pd,close,monitor");
                if (!pd_monitor) {
-                       ErrPrint("There is no requests to release pd buffer\n");
+                       ErrPrint("Slave requests to release a buffer\n");
                        /*!
                         * \note
                         * In this case just keep going to release buffer,