From f027276082c75dc5d261e0c4ecf69c026c27b329 Mon Sep 17 00:00:00 2001 From: Sung-jae Park Date: Fri, 12 Apr 2013 11:34:10 +0900 Subject: [PATCH] Fix the issues which are reported from the prevent Change-Id: I844849718d3ceeb647aa4c1943572bc0d616c22f --- src/server.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 56 insertions(+), 14 deletions(-) diff --git a/src/server.c b/src/server.c index 380f209..4932f7f 100644 --- a/src/server.c +++ b/src/server.c @@ -1519,7 +1519,7 @@ out: static int inst_del_cb(struct inst_info *inst, void *data) { - event_deactivate(); + (void)event_deactivate(); return -1; /* Delete this callback */ } @@ -3486,7 +3486,7 @@ static struct packet *client_lb_access_hl(pid_t pid, int handle, const struct pa } ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y); - if (ret != 7) { + if (ret != 5) { ErrPrint("Parameter is not matched\n"); ret = LB_STATUS_ERROR_INVALID; goto out; @@ -3620,7 +3620,7 @@ static struct packet *client_lb_access_hl_prev(pid_t pid, int handle, const stru } ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y); - if (ret != 7) { + if (ret != 5) { ErrPrint("Parameter is not matched\n"); ret = LB_STATUS_ERROR_INVALID; goto out; @@ -3754,7 +3754,7 @@ static struct packet *client_lb_access_hl_next(pid_t pid, int handle, const stru } ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y); - if (ret != 7) { + if (ret != 5) { ErrPrint("Parameter is not matched\n"); ret = LB_STATUS_ERROR_INVALID; goto out; @@ -3883,28 +3883,33 @@ static struct packet *client_lb_access_value_change(pid_t pid, int handle, const client = client_find_by_pid(pid); if (!client) { ErrPrint("Client %d is not exist\n", pid); + ret = LB_STATUS_ERROR_NOT_EXIST; goto out; } ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y); if (ret != 5) { - ErrPrint("Invalid argument\n"); + ErrPrint("Parameter is not matched\n"); + ret = LB_STATUS_ERROR_INVALID; goto out; } inst = package_find_instance_by_id(pkgname, id); if (!inst) { ErrPrint("Instance[%s] is not exists\n", id); + ret = LB_STATUS_ERROR_NOT_EXIST; goto out; } pkg = instance_package(inst); if (!pkg) { ErrPrint("Package[%s] info is not exists\n", pkgname); + ret = LB_STATUS_ERROR_FAULT; goto out; } if (package_is_fault(pkg)) { + ret = LB_STATUS_ERROR_FAULT; } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) { struct buffer_info *buffer; struct slave_node *slave; @@ -3912,12 +3917,14 @@ static struct packet *client_lb_access_value_change(pid_t pid, int handle, const buffer = instance_lb_buffer(inst); if (!buffer) { ErrPrint("Instance[%s] has no buffer\n", id); + ret = LB_STATUS_ERROR_FAULT; goto out; } slave = package_slave(pkg); if (!slave) { ErrPrint("Slave is not exists\n"); + ret = LB_STATUS_ERROR_INVALID; goto out; } @@ -3935,12 +3942,14 @@ static struct packet *client_lb_access_value_change(pid_t pid, int handle, const script = instance_lb_script(inst); if (!script) { ErrPrint("Instance has no script\n"); + ret = LB_STATUS_ERROR_FAULT; goto out; } e = script_handler_evas(script); if (!e) { ErrPrint("Script has no evas\n"); + ret = LB_STATUS_ERROR_INVALID; goto out; } @@ -3967,6 +3976,7 @@ static struct packet *client_lb_access_value_change(pid_t pid, int handle, const } } else { ErrPrint("Unsupported package\n"); + ret = LB_STATUS_ERROR_INVALID; } out: @@ -3998,7 +4008,7 @@ static struct packet *client_lb_access_unhighlight(pid_t pid, int handle, const } ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y); - if (ret != 7) { + if (ret != 5) { ErrPrint("Parameter is not matched\n"); ret = LB_STATUS_ERROR_INVALID; goto out; @@ -4127,28 +4137,33 @@ static struct packet *client_lb_access_scroll(pid_t pid, int handle, const struc client = client_find_by_pid(pid); if (!client) { ErrPrint("Client %d is not exist\n", pid); + ret = LB_STATUS_ERROR_NOT_EXIST; goto out; } ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y); if (ret != 5) { - ErrPrint("Invalid argument\n"); + ErrPrint("Parameter is not matched\n"); + ret = LB_STATUS_ERROR_INVALID; goto out; } inst = package_find_instance_by_id(pkgname, id); if (!inst) { ErrPrint("Instance[%s] is not exists\n", id); + ret = LB_STATUS_ERROR_NOT_EXIST; goto out; } pkg = instance_package(inst); if (!pkg) { ErrPrint("Package[%s] info is not exists\n", pkgname); + ret = LB_STATUS_ERROR_FAULT; goto out; } if (package_is_fault(pkg)) { + ret = LB_STATUS_ERROR_FAULT; } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) { struct buffer_info *buffer; struct slave_node *slave; @@ -4156,12 +4171,14 @@ static struct packet *client_lb_access_scroll(pid_t pid, int handle, const struc buffer = instance_lb_buffer(inst); if (!buffer) { ErrPrint("Instance[%s] has no buffer\n", id); + ret = LB_STATUS_ERROR_FAULT; goto out; } slave = package_slave(pkg); if (!slave) { ErrPrint("Slave is not exists\n"); + ret = LB_STATUS_ERROR_INVALID; goto out; } @@ -4179,12 +4196,14 @@ static struct packet *client_lb_access_scroll(pid_t pid, int handle, const struc script = instance_lb_script(inst); if (!script) { ErrPrint("Instance has no script\n"); + ret = LB_STATUS_ERROR_FAULT; goto out; } e = script_handler_evas(script); if (!e) { ErrPrint("Instance has no evas\n"); + ret = LB_STATUS_ERROR_INVALID; goto out; } @@ -4211,6 +4230,7 @@ static struct packet *client_lb_access_scroll(pid_t pid, int handle, const struc } } else { ErrPrint("Unsupported package\n"); + ret = LB_STATUS_ERROR_INVALID; } out: @@ -4242,8 +4262,9 @@ static struct packet *client_lb_access_activate(pid_t pid, int handle, const str } ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y); - if (ret != 7) { + if (ret != 5) { ErrPrint("Parameter is not matched\n"); + ret = LB_STATUS_ERROR_INVALID; goto out; } @@ -4255,12 +4276,14 @@ static struct packet *client_lb_access_activate(pid_t pid, int handle, const str inst = package_find_instance_by_id(pkgname, id); if (!inst) { ErrPrint("Instance[%s] is not exists\n", id); + ret = LB_STATUS_ERROR_NOT_EXIST; goto out; } pkg = instance_package(inst); if (!pkg) { ErrPrint("Package[%s] info is not exists\n", pkgname); + ret = LB_STATUS_ERROR_INVALID; goto out; } @@ -4271,6 +4294,7 @@ static struct packet *client_lb_access_activate(pid_t pid, int handle, const str * slave has not load it, so we don't need to do anything at here! */ DbgPrint("Package[%s] is faulted\n", pkgname); + ret = LB_STATUS_ERROR_FAULT; } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) { struct buffer_info *buffer; struct slave_node *slave; @@ -4279,12 +4303,14 @@ static struct packet *client_lb_access_activate(pid_t pid, int handle, const str buffer = instance_lb_buffer(inst); if (!buffer) { ErrPrint("Instance[%s] has no buffer\n", id); + ret = LB_STATUS_ERROR_FAULT; goto out; } slave = package_slave(pkg); if (!slave) { ErrPrint("Package[%s] has no slave\n", pkgname); + ret = LB_STATUS_ERROR_INVALID; goto out; } @@ -4306,12 +4332,14 @@ static struct packet *client_lb_access_activate(pid_t pid, int handle, const str script = instance_lb_script(inst); if (!script) { ErrPrint("Instance has no script\n"); + ret = LB_STATUS_ERROR_FAULT; goto out; } e = script_handler_evas(script); if (!e) { ErrPrint("Script has no Evas\n"); + ret = LB_STATUS_ERROR_INVALID; goto out; } @@ -4338,6 +4366,7 @@ static struct packet *client_lb_access_activate(pid_t pid, int handle, const str } } else { ErrPrint("Unsupported package\n"); + ret = LB_STATUS_ERROR_INVALID; } out: @@ -4595,6 +4624,7 @@ static struct packet *client_lb_acquire_pixmap(pid_t pid, int handle, const stru int ret; int pixmap = 0; void *buf_ptr; + struct buffer_info *buffer; client = client_find_by_pid(pid); if (!client) { @@ -4620,8 +4650,13 @@ static struct packet *client_lb_acquire_pixmap(pid_t pid, int handle, const stru } DbgPrint("pid[%d] pkgname[%s] id[%s]\n", pid, pkgname, id); + buffer = instance_lb_buffer(inst); + if (!buffer) { + ErrPrint("Unable to get LB buffer: %s\n", id); + goto out; + } - buf_ptr = buffer_handler_pixmap_ref(instance_lb_buffer(inst)); + buf_ptr = buffer_handler_pixmap_ref(buffer); if (!buf_ptr) { ErrPrint("Failed to ref pixmap\n"); goto out; @@ -4631,9 +4666,8 @@ static struct packet *client_lb_acquire_pixmap(pid_t pid, int handle, const stru if (ret < 0) { ErrPrint("Failed to add a new client deactivate callback\n"); buffer_handler_pixmap_unref(buf_ptr); - pixmap = 0; } else { - pixmap = buffer_handler_pixmap(instance_lb_buffer(inst)); + pixmap = buffer_handler_pixmap(buffer); } out: @@ -4702,6 +4736,7 @@ static struct packet *client_pd_acquire_pixmap(pid_t pid, int handle, const stru int ret; int pixmap = 0; void *buf_ptr; + struct buffer_info *buffer; client = client_find_by_pid(pid); if (!client) { @@ -4727,8 +4762,13 @@ static struct packet *client_pd_acquire_pixmap(pid_t pid, int handle, const stru } DbgPrint("pid[%d] pkgname[%s] id[%s]\n", pid, pkgname, id); + buffer = instance_pd_buffer(inst); + if (!buffer) { + ErrPrint("Unable to get PD buffer (%s)\n", id); + goto out; + } - buf_ptr = buffer_handler_pixmap_ref(instance_pd_buffer(inst)); + buf_ptr = buffer_handler_pixmap_ref(buffer); if (!buf_ptr) { ErrPrint("Failed to ref pixmap\n"); goto out; @@ -4738,7 +4778,7 @@ static struct packet *client_pd_acquire_pixmap(pid_t pid, int handle, const stru if (ret < 0) buffer_handler_pixmap_unref(buf_ptr); - pixmap = buffer_handler_pixmap(instance_pd_buffer(inst)); + pixmap = buffer_handler_pixmap(buffer); out: result = packet_create_reply(packet, "i", pixmap); if (!result) @@ -6430,11 +6470,13 @@ static struct packet *service_update(pid_t pid, int handle, const struct packet pkg = package_find(lb_pkgname); if (!pkg) { ret = LB_STATUS_ERROR_NOT_EXIST; + DbgFree(lb_pkgname); goto out; } if (package_is_fault(pkg)) { ret = LB_STATUS_ERROR_FAULT; + DbgFree(lb_pkgname); goto out; } @@ -6444,7 +6486,7 @@ static struct packet *service_update(pid_t pid, int handle, const struct packet */ slave_rpc_request_update(lb_pkgname, id, cluster, category); DbgFree(lb_pkgname); - ret = 0; + ret = LB_STATUS_SUCCESS; out: result = packet_create_reply(packet, "i", ret); -- 2.7.4