Sync with the latest private code. 85/20185/1 accepted/tizen_mobile tizen accepted/tizen/mobile/20140702.100559 submit/tizen/20140430.015959
authorSung-jae Park <nicesj.park@samsung.com>
Tue, 29 Apr 2014 07:24:25 +0000 (16:24 +0900)
committerSung-jae Park <nicesj.park@samsung.com>
Tue, 29 Apr 2014 07:25:02 +0000 (16:25 +0900)
commit faed5745e11faec2a6107eda7b036b8682c4e952
Author: Sung-jae Park <nicesj.park@samsung.com>
Date:   Fri Apr 18 14:03:53 2014 +0900
    Change the app-name

commit 2735c957022c72d376ea885d8dcb187781bb0fd2
Author: Sung-jae Park <nicesj.park@samsung.com>
Date:   Fri Apr 18 11:36:27 2014 +0900
    Update the deleted/updated callback call routine.

    While processing the updated/deleted callback, any item can be deleted.
    Using in_use flag, if there is deleting request while processing callback list,
    don't delete item directly just toggle the deleted flag.
    After callback call, check the deleted flag. if the deleted flag is toggled,
    Then delete it from the list safely.

Change-Id: I01fcbecb11aa6147c57a47143753a6f9d65f78f1

org.tizen.data-provider-slave.xml
packaging/org.tizen.data-provider-slave.spec
src/lb.c
src/update_monitor.c

index cb77e6f..c9c8dad 100644 (file)
@@ -1,14 +1,14 @@
 <?xml version="1.0" encoding="utf-8" ?>
 <manifest xmlns="http://tizen.org/ns/packages" package="org.tizen.data-provider-slave" version="0.5.4" install-location="auto">
 <?xml version="1.0" encoding="utf-8" ?>
 <manifest xmlns="http://tizen.org/ns/packages" package="org.tizen.data-provider-slave" version="0.5.4" install-location="auto">
-       <label>Dynamic Box Provider (Default)</label>
+       <label>Dynamic Box Provider (slave)</label>
        <author email="nicesj.park@samsung.com" href="www.samsung.com">Sung-jae Park</author>
        <author email="yjoo93.park@samsung.com" href="www.samsung.com">Youngjoo Park</author>
        <author email="nicesj.park@samsung.com" href="www.samsung.com">Sung-jae Park</author>
        <author email="yjoo93.park@samsung.com" href="www.samsung.com">Youngjoo Park</author>
-       <description>Dynamic Box Provider (Default)</description>
+       <description>Dynamic Box Provider (slave)</description>
 
        <ui-application appid="org.tizen.data-provider-slave" exec="/usr/apps/org.tizen.data-provider-slave/bin/data-provider-slave" nodisplay="true" multiple="true" type="capp" taskmanage="false">
                <icon>org.tizen.data-provider-slave.png</icon>
                <label>Dynamic Box Provider (Default)</label>
 
        <ui-application appid="org.tizen.data-provider-slave" exec="/usr/apps/org.tizen.data-provider-slave/bin/data-provider-slave" nodisplay="true" multiple="true" type="capp" taskmanage="false">
                <icon>org.tizen.data-provider-slave.png</icon>
                <label>Dynamic Box Provider (Default)</label>
-               <label xml:lang="en-us">Dynamic Box Provider (Default)</label>
+               <label xml:lang="en-us">Dynamic Box Provider (slave)</label>
        </ui-application>
 
        <ui-application appid="org.tizen.data-provider-slave.icon" exec="/usr/apps/org.tizen.data-provider-slave/bin/icon-provider-slave" nodisplay="true" multiple="false" type="capp" taskmanage="false">
        </ui-application>
 
        <ui-application appid="org.tizen.data-provider-slave.icon" exec="/usr/apps/org.tizen.data-provider-slave/bin/icon-provider-slave" nodisplay="true" multiple="false" type="capp" taskmanage="false">
index bf87e96..906d743 100644 (file)
@@ -2,7 +2,7 @@
 
 Name: org.tizen.data-provider-slave
 Summary: Plugin type livebox service provider
 
 Name: org.tizen.data-provider-slave
 Summary: Plugin type livebox service provider
-Version: 0.13.4
+Version: 0.14.0
 Release: 1
 Group: HomeTF/Livebox
 License: Flora
 Release: 1
 Group: HomeTF/Livebox
 License: Flora
index 64fef83..946f88d 100644 (file)
--- a/src/lb.c
+++ b/src/lb.c
@@ -945,6 +945,11 @@ static int file_updated_cb(const char *filename, void *data, int over)
 
        item = data;
 
 
        item = data;
 
+       if (item->deleteme) {
+               DbgPrint("Item is in deleting process. (%s)\n", filename);
+               goto out;
+       }
+
        ESTIMATE_START(item->inst->id);
 
        ret = util_get_filesize(filename);
        ESTIMATE_START(item->inst->id);
 
        ret = util_get_filesize(filename);
@@ -979,6 +984,7 @@ static int file_updated_cb(const char *filename, void *data, int over)
        }
 
        ESTIMATE_END(item->inst->id);
        }
 
        ESTIMATE_END(item->inst->id);
+out:
        return output_handler(item);
 }
 
        return output_handler(item);
 }
 
index 4027d22..f848fa1 100644 (file)
@@ -40,6 +40,7 @@ struct cb_item {
        char *filename;
        int (*cb)(const char *filename, void *data, int over);
        void *data;
        char *filename;
        int (*cb)(const char *filename, void *data, int over);
        void *data;
+       int deleted;
 };
 
 static struct info {
 };
 
 static struct info {
@@ -48,14 +49,52 @@ static struct info {
        Ecore_Fd_Handler *handler;
        Eina_List *update_list;
        Eina_List *delete_list;
        Ecore_Fd_Handler *handler;
        Eina_List *update_list;
        Eina_List *delete_list;
+       unsigned int update_list_in_use;
+       unsigned int delete_list_in_use;
 } s_info = {
        .ifd = -EINVAL,
        .iwd = -EINVAL,
        .handler = NULL,
        .update_list = NULL,
        .delete_list = NULL,
 } s_info = {
        .ifd = -EINVAL,
        .iwd = -EINVAL,
        .handler = NULL,
        .update_list = NULL,
        .delete_list = NULL,
+       .update_list_in_use = 0,
+       .delete_list_in_use = 0,
 };
 
 };
 
+static void *update_item_destroy(struct cb_item *item, Eina_List *l)
+{
+       void *data;
+
+       if (s_info.update_list_in_use) {
+               item->deleted = 1;
+               data = item->data;
+       } else {
+               s_info.update_list = eina_list_remove_list(s_info.update_list, l);
+               data = item->data;
+               free(item->filename);
+               free(item);
+       }
+
+       return data;
+}
+
+static void *delete_item_destroy(struct cb_item *item, Eina_List *l)
+{
+       void *data;
+
+       if (s_info.delete_list_in_use == 1) {
+               item->deleted = 1;
+               data = item->data;
+       } else {
+               s_info.delete_list = eina_list_remove_list(s_info.delete_list, l);
+               data = item->data;
+               free(item->filename);
+               free(item);
+       }
+
+       return data;
+}
+
 static Eina_Bool monitor_cb(void *data, Ecore_Fd_Handler *handler)
 {
        int fd;
 static Eina_Bool monitor_cb(void *data, Ecore_Fd_Handler *handler)
 {
        int fd;
@@ -216,10 +255,11 @@ HAPI int update_monitor_trigger_update_cb(const char *filename, int over)
        struct cb_item *item;
        int cnt = 0;
 
        struct cb_item *item;
        int cnt = 0;
 
+       s_info.update_list_in_use = 1;
        EINA_LIST_FOREACH_SAFE(s_info.update_list, l, n, item) {
        EINA_LIST_FOREACH_SAFE(s_info.update_list, l, n, item) {
-               if (!strcmp(filename, item->filename) && item->cb(filename, item->data, over) == EXIT_FAILURE) {
-                       /* Item can be deleted from the callback, so need to check existence */
-                       if (eina_list_data_find(s_info.update_list, item)) {
+               if (!strcmp(filename, item->filename)) {
+                       if (item->deleted || item->cb(filename, item->data, over) == EXIT_FAILURE || item->deleted) {
+                               /* Item can be deleted from the callback, so need to check existence */
                                s_info.update_list = eina_list_remove_list(s_info.update_list, l);
                                free(item->filename);
                                free(item);
                                s_info.update_list = eina_list_remove_list(s_info.update_list, l);
                                free(item->filename);
                                free(item);
@@ -227,6 +267,7 @@ HAPI int update_monitor_trigger_update_cb(const char *filename, int over)
                        cnt++;
                }
        }
                        cnt++;
                }
        }
+       s_info.update_list_in_use = 0;
 
        return cnt == 0 ? LB_STATUS_ERROR_INVALID : LB_STATUS_SUCCESS;
 }
 
        return cnt == 0 ? LB_STATUS_ERROR_INVALID : LB_STATUS_SUCCESS;
 }
@@ -238,17 +279,20 @@ HAPI int update_monitor_trigger_delete_cb(const char *filename, int over)
        struct cb_item *item;
        int cnt = 0;
 
        struct cb_item *item;
        int cnt = 0;
 
+       s_info.delete_list_in_use = 1;
        EINA_LIST_FOREACH_SAFE(s_info.delete_list, l, n, item) {
        EINA_LIST_FOREACH_SAFE(s_info.delete_list, l, n, item) {
-               if (!strcmp(filename, item->filename) && item->cb(filename, item->data, over) == EXIT_FAILURE) {
-                       /* Item can be deleted from the callback, so need to check existence. */
-                       if (eina_list_data_find(s_info.delete_list, item)) {
+               if (!strcmp(filename, item->filename)) {
+                       /* delete should be checked before call the callback & after call the callback */
+                       if (item->deleted || item->cb(filename, item->data, over) == EXIT_FAILURE || item->deleted) {
                                s_info.delete_list = eina_list_remove_list(s_info.delete_list, l);
                                free(item->filename);
                                free(item);
                        }
                                s_info.delete_list = eina_list_remove_list(s_info.delete_list, l);
                                free(item->filename);
                                free(item);
                        }
+
                        cnt++;
                }
        }
                        cnt++;
                }
        }
+       s_info.delete_list_in_use = 0;
 
        return cnt == 0 ? LB_STATUS_ERROR_INVALID : LB_STATUS_SUCCESS;
 }
 
        return cnt == 0 ? LB_STATUS_ERROR_INVALID : LB_STATUS_SUCCESS;
 }
@@ -307,15 +351,10 @@ HAPI void *update_monitor_del_update_cb(const char *filename,
 {
        Eina_List *l;
        struct cb_item *item;
 {
        Eina_List *l;
        struct cb_item *item;
-       void *data;
 
        EINA_LIST_FOREACH(s_info.update_list, l, item) {
                if (item->cb == cb && !strcmp(item->filename, filename)) {
 
        EINA_LIST_FOREACH(s_info.update_list, l, item) {
                if (item->cb == cb && !strcmp(item->filename, filename)) {
-                       s_info.update_list = eina_list_remove_list(s_info.update_list, l);
-                       data = item->data;
-                       free(item->filename);
-                       free(item);
-                       return data;
+                       return update_item_destroy(item, l);
                }
        }
 
                }
        }
 
@@ -327,15 +366,10 @@ HAPI void *update_monitor_del_delete_cb(const char *filename,
 {
        Eina_List *l;
        struct cb_item *item;
 {
        Eina_List *l;
        struct cb_item *item;
-       void *data;
 
        EINA_LIST_FOREACH(s_info.delete_list, l, item) {
                if (item->cb == cb && !strcmp(item->filename, filename)) {
 
        EINA_LIST_FOREACH(s_info.delete_list, l, item) {
                if (item->cb == cb && !strcmp(item->filename, filename)) {
-                       s_info.delete_list = eina_list_remove_list(s_info.delete_list, l);
-                       data = item->data;
-                       free(item->filename);
-                       free(item);
-                       return data;
+                       return delete_item_destroy(item, l);
                }
        }
 
                }
        }