summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaehyeon Jung <darrenh.jung@samsung.com>2016-05-17 21:12:53 +0900
committerDaehyeon Jung <darrenh.jung@samsung.com>2016-05-19 08:31:39 +0900
commit87d9b1a3a4b4e57d321ab08e27adfebbadd87ecb (patch)
tree90506cc520a80b6bc462bd886e1eec35b3159cf7
parent8097d51fbb8c06b0423dad3d5c2b697c9dd412a3 (diff)
downloadwidget-service-87d9b1a3a4b4e57d321ab08e27adfebbadd87ecb.tar.gz
widget-service-87d9b1a3a4b4e57d321ab08e27adfebbadd87ecb.tar.bz2
widget-service-87d9b1a3a4b4e57d321ab08e27adfebbadd87ecb.zip
- In widget crash, notify WIDGET_INSTANCE_EVENT_FAULT to instance handler - Fix some possible memory leaks Change-Id: Ic4f7798724ef5463c2d4a445772a9efba0f5689b Signed-off-by: Daehyeon Jung <darrenh.jung@samsung.com>
-rw-r--r--src/widget_instance.c62
1 files changed, 52 insertions, 10 deletions
diff --git a/src/widget_instance.c b/src/widget_instance.c
index bd7f764..787b25a 100644
--- a/src/widget_instance.c
+++ b/src/widget_instance.c
@@ -658,9 +658,13 @@ EAPI int widget_instance_launch(const char *widget_id, const char *instance_id,
EAPI int widget_instance_terminate(const char *widget_id, const char *instance_id)
{
int ret = 0;
- bundle *b = bundle_create();
+ bundle *b = NULL;
- if (widget_id == NULL || instance_id == NULL || b == NULL)
+ if (widget_id == NULL || instance_id == NULL)
+ return -1;
+
+ b = bundle_create();
+ if (b == NULL)
return -1;
bundle_add_str(b, WIDGET_K_OPERATION, "terminate");
@@ -675,9 +679,13 @@ EAPI int widget_instance_terminate(const char *widget_id, const char *instance_i
EAPI int widget_instance_destroy(const char *widget_id, const char *instance_id)
{
int ret = 0;
- bundle *b = bundle_create();
+ bundle *b = NULL;
- if (widget_id == NULL || instance_id == NULL || b == NULL)
+ if (widget_id == NULL || instance_id == NULL)
+ return -1;
+
+ b = bundle_create();
+ if (b == NULL)
return -1;
bundle_add_str(b, WIDGET_K_OPERATION, "destroy");
@@ -692,9 +700,13 @@ EAPI int widget_instance_destroy(const char *widget_id, const char *instance_id)
EAPI int widget_instance_resume(const char *widget_id, const char *instance_id)
{
int ret = 0;
- bundle *b = bundle_create();
+ bundle *b = NULL;
- if (widget_id == NULL || instance_id == NULL || b == NULL)
+ if (widget_id == NULL || instance_id == NULL)
+ return -1;
+
+ b = bundle_create();
+ if (b == NULL)
return -1;
bundle_add_str(b, WIDGET_K_OPERATION, "resume");
@@ -709,9 +721,13 @@ EAPI int widget_instance_resume(const char *widget_id, const char *instance_id)
EAPI int widget_instance_pause(const char *widget_id, const char *instance_id)
{
int ret = 0;
- bundle *b = bundle_create();
+ bundle *b = NULL;
- if (widget_id == NULL || instance_id == NULL || b == NULL)
+ if (widget_id == NULL || instance_id == NULL)
+ return -1;
+
+ b = bundle_create();
+ if (b == NULL)
return -1;
bundle_add_str(b, WIDGET_K_OPERATION, "pause");
@@ -726,9 +742,13 @@ EAPI int widget_instance_pause(const char *widget_id, const char *instance_id)
EAPI int widget_instance_resize(const char *widget_id, const char *instance_id, int w, int h)
{
int ret = 0;
- bundle *b = bundle_create();
+ bundle *b = NULL;
- if (widget_id == NULL || instance_id == NULL || b == NULL)
+ if (widget_id == NULL || instance_id == NULL)
+ return -1;
+
+ b = bundle_create();
+ if (b == NULL)
return -1;
bundle_add_str(b, WIDGET_K_OPERATION, "resize");
@@ -910,6 +930,27 @@ static int __widget_handler(const char *viewer_id, aul_app_com_result_e e, bundl
return 0;
}
+static int __fault_handler(int pid, void *data)
+{
+ GList *iter;
+ struct _widget_instance *instance;
+
+ iter = _widget_instances;
+
+ while (iter) {
+ instance = (struct _widget_instance *)iter->data;
+ if (instance && instance->pid == pid) {
+ instance->pid = 0;
+ instance->status = WIDGET_INSTANCE_TERMINATED;
+ __update_instance_info(instance);
+ __notify_event(WIDGET_INSTANCE_EVENT_FAULT, instance->widget_id, instance->id);
+ }
+ iter = iter->next;
+ }
+
+ return 0;
+}
+
EAPI int widget_instance_init(const char *viewer_id)
{
if (viewer_id == NULL)
@@ -920,6 +961,7 @@ EAPI int widget_instance_init(const char *viewer_id)
__init(false);
__load_instance_list();
__connect_status_handler();
+ aul_listen_app_dead_signal(__fault_handler, NULL);
if (aul_app_com_create(viewer_id, NULL, __widget_handler, NULL, &conn_viewer) < 0) {
_E("failed to create app com endpoint");