Check the PD owner.
authorSung-jae Park <nicesj.park@samsung.com>
Fri, 14 Jun 2013 05:50:57 +0000 (14:50 +0900)
committerSung-jae Park <nicesj.park@samsung.com>
Fri, 14 Jun 2013 05:50:57 +0000 (14:50 +0900)
[model] Tizen
[binary_type] AP
[customer] Tizen Developer
[issue#] N/A
[problem] No one can open or close the PD if it is not owned by requestor.
[cause] N/A
[solution] N/A
[team] HomeTF
[request]
[horizontal_expansion]

Change-Id: If4bbe6917507392fed21d3bca8bb791b379c24ef

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

index 54ba80a..42c2bc3 100644 (file)
@@ -221,6 +221,8 @@ 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);
+
 /*!
  * Multiple viewer
  */
index 66f3f66..4c9b77e 100644 (file)
@@ -1,6 +1,6 @@
 Name: data-provider-master
 Summary: Master service provider for liveboxes.
-Version: 0.24.7
+Version: 0.24.8
 Release: 1
 Group: HomeTF/Livebox
 License: Flora License
index 8bf38f9..c87685d 100644 (file)
@@ -3121,4 +3121,9 @@ 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)
+{
+       return inst->pd.owner;
+}
+
 /* End of a file */
index 07aad34..e4a2b8e 100644 (file)
@@ -4713,6 +4713,8 @@ static struct packet *client_create_pd(pid_t pid, int handle, const struct packe
 
        if (util_free_space(IMAGE_PATH) < MINIMUM_SPACE) {
                ret = LB_STATUS_ERROR_NO_SPACE;
+       } else if (instance_pd_owner(inst)) {
+               ret = LB_STATUS_ERROR_ALREADY;
        } else if (package_pd_type(instance_package(inst)) == PD_TYPE_BUFFER) {
                lazy_pd_destroyed_cb(inst);
                
@@ -4890,7 +4892,9 @@ static struct packet *client_destroy_pd(pid_t pid, int handle, const struct pack
        if (ret != LB_STATUS_SUCCESS)
                goto out;
 
-       if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
+       if (instance_pd_owner(inst) != client) {
+               ret = instance_pd_owner(inst) == NULL ? LB_STATUS_ERROR_ALREADY : LB_STATUS_ERROR_PERMISSION;
+       } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
                int resize_aborted = 0;
 
                pd_monitor = instance_del_data(inst, "pd,open,monitor");
@@ -4927,6 +4931,11 @@ static struct packet *client_destroy_pd(pid_t pid, int handle, const struct pack
                        goto out;
                }
 
+               if (instance_get_data(inst, "lazy,pd,close") || instance_get_data(inst, "pd,close,monitor")) {
+                       ret = LB_STATUS_ERROR_ALREADY;
+                       goto out;
+               }
+
                pd_monitor = instance_del_data(inst, "pd,resize,monitor");
                if (pd_monitor) {
                        ErrPrint("PD Resize request is found. clear it [%s]\n", pkgname);