fix bug: cleanup thread is not working 70/168770/1 accepted/tizen/unified/20180201.075949 submit/tizen/20180131.030057
authorJeesun Kim <iamjs.kim@samsung.com>
Tue, 30 Jan 2018 09:48:24 +0000 (18:48 +0900)
committerjeesun kim <iamjs.kim@samsung.com>
Wed, 31 Jan 2018 00:35:56 +0000 (00:35 +0000)
Change-Id: I994d773dd777021fdee560af109dc4fdd19c6c0f

server/cal_server_cleanup.h
server/db/cal_db.c
server/db/cal_db_plugin_book.c

index d422b79..bf8e256 100644 (file)
@@ -21,5 +21,6 @@
 
 void cal_server_cleanup_start(void);
 void cal_server_cleanup_end(void);
+void cal_server_cleanup_send_signal(void);
 
 #endif /*__CAL_SERVER_CLEANUP_H__*/
index 97f777f..722f5f0 100644 (file)
@@ -31,6 +31,7 @@
 #include "cal_list.h"
 #include "cal_db.h"
 #include "cal_access_control.h"
+#include "cal_server_cleanup.h"
 #include "cal_utils.h"
 
 #define BULK_DEFAULT_COUNT 100
@@ -472,6 +473,8 @@ int cal_db_delete_record(const char* view_uri, int id)
        else
                cal_db_util_end_trans(false);
 
+       cal_server_cleanup_send_signal();
+
        return ret;
 }
 
@@ -858,6 +861,8 @@ int cal_db_delete_records(const char* view_uri, int record_id_array[], int count
        else
                cal_db_util_end_trans(false);
 
+       cal_server_cleanup_send_signal();
+
        return ret;
 }
 
index 767398d..041ad85 100644 (file)
@@ -300,62 +300,18 @@ static int _cal_db_book_delete_record(int id)
 {
        int ret = CALENDAR_ERROR_NONE;
        char query[CAL_DB_SQL_MAX_LEN] = {0};
-       int calendar_book_id = -1;
 
-       snprintf(query, sizeof(query), "SELECT id FROM %s WHERE id = %d",
-                       CAL_TABLE_CALENDAR, id);
-       ret = cal_db_util_query_get_first_int_result(query, NULL, &calendar_book_id);
-       if (CALENDAR_ERROR_NONE != ret) {
-               /* LCOV_EXCL_START */
-               ERR("cal_db_util_query_get_first_int_result() Fail(%d)", ret);
-               return ret;
-               /* LCOV_EXCL_STOP */
-       }
-
-       int count = 0;
-       int count2 = 0;
-       snprintf(query, sizeof(query), "select count(*) from %s", CAL_TABLE_UTIME_INSTANCE);
-       ret = cal_db_util_query_get_first_int_result(query, NULL, &count);
-       if (CALENDAR_ERROR_NONE != ret) {
-               /* LCOV_EXCL_START */
-               ERR("cal_db_util_query_get_first_int_result() Fail");
-               return ret;
-               /* LCOV_EXCL_STOP */
-       }
-
-       snprintf(query, sizeof(query), "select count(*) from %s", CAL_TABLE_LOCALTIME_INSTANCE);
-       ret = cal_db_util_query_get_first_int_result(query, NULL, &count2);
-       if (CALENDAR_ERROR_NONE != ret) {
-               /* LCOV_EXCL_START */
-               ERR("cal_db_util_query_get_first_int_result() Fail");
-               return ret;
-               /* LCOV_EXCL_STOP */
-       }
-
-       count += count2;
-
-       if (1000 < count) {
-               snprintf(query, sizeof(query), "UPDATE %s SET deleted = 1 WHERE id = %d", CAL_TABLE_CALENDAR, id);
-               ret = cal_db_util_query_exec(query);
-               RETVM_IF(CALENDAR_ERROR_NONE != ret, ret, "cal_db_util_query_exec() Fail(%d)", ret);
-               cal_server_cleanup_start();
-       } else {
-               snprintf(query, sizeof(query), "DELETE FROM %s WHERE id = %d", CAL_TABLE_CALENDAR, id);
-               ret = cal_db_util_query_exec(query);
-               RETVM_IF(CALENDAR_ERROR_NONE != ret, ret, "cal_db_util_query_exec() Fail(%d)", ret);
-
-               snprintf(query, sizeof(query), "DELETE FROM %s WHERE calendar_id = %d", CAL_TABLE_SCHEDULE, id);
-               ret = cal_db_util_query_exec(query);
-               RETVM_IF(CALENDAR_ERROR_NONE != ret, ret, "cal_db_util_query_exec() Fail(%d)", ret);
-       }
+       snprintf(query, sizeof(query), "UPDATE %s SET deleted = 1 WHERE id = %d", CAL_TABLE_CALENDAR, id);
+       ret = cal_db_util_query_exec(query);
+       RETVM_IF(CALENDAR_ERROR_NONE != ret, ret, "cal_db_util_query_exec() Fail(%d)", ret);
 
-       snprintf(query, sizeof(query), "DELETE FROM %s WHERE calendar_id = %d", CAL_TABLE_DELETED, id);
+       snprintf(query, sizeof(query), "DELETE FROM "CAL_TABLE_DELETED" WHERE calendar_id = %d", id);
        ret = cal_db_util_query_exec(query);
        RETVM_IF(CALENDAR_ERROR_NONE != ret, ret, "cal_db_util_query_exec() Fail(%d)", ret);
 
        cal_access_control_reset();
-
        cal_db_util_notify(CAL_NOTI_TYPE_BOOK);
+
        return CALENDAR_ERROR_NONE;
 }