Fix the Crash for increase max ids limit 09/118609/1
authorHyeKyoung Hwang <cookie@samsung.com>
Mon, 13 Mar 2017 08:43:37 +0000 (17:43 +0900)
committerHyeKyoung Hwang <cookie@samsung.com>
Mon, 13 Mar 2017 08:43:37 +0000 (17:43 +0900)
[Problem] Cloud pdm sync server is crashing due to less limit
[Cause & Measure] Increase the limit and do proper check
[Checking Method] Keep a lot of tabs to sync, launch cloud pdm syn

Change-Id: I0f272b9786229460168d82431692ba4f16a85f41
Signed-off-by: HyeKyoung Hwang <cookie@samsung.com>
bookmark-adaptor/bookmark-adaptor.c
bookmark-csc-adaptor/bookmark-csc-adaptor.c
common-adaptor/common-adaptor.c
common-adaptor/include/common-adaptor.h
history-adaptor/history-adaptor.c
tab-adaptor/tab-adaptor.c

index da0144bf03d4d347761061ce1e405f020deb6d48..e642d14c4dc9eca49e732bb9f10f0bf7c6a855d9 100755 (executable)
@@ -1011,7 +1011,7 @@ static int __bp_bookmark_adaptor_get_cond_ids_p
        // int count.
        int ids_count = bp_adaptor_ipc_read_int(sock);
        TRACE_DEBUG("response ids count:%d", ids_count);
-       if (ids_count < 256 && ids_count > 0) {
+       if (ids_count < BP_MAX_IDS_COUNT && ids_count > 0) {
                int *idlist = (int *)calloc(ids_count, sizeof(int));
                if (idlist == NULL) {
                        errorcode = BP_ERROR_OUT_OF_MEMORY;
@@ -1156,7 +1156,7 @@ int bp_bookmark_adaptor_get_timestamp_ids_p
        // int count.
        int ids_count = bp_adaptor_ipc_read_int(sock);
        TRACE_DEBUG("response ids count:%d", ids_count);
-       if (ids_count < 256 && ids_count > 0) {
+       if (ids_count < BP_MAX_IDS_COUNT && ids_count > 0) {
                int *idlist = (int *)calloc(ids_count, sizeof(int));
                if (idlist == NULL) {
                        errorcode = BP_ERROR_OUT_OF_MEMORY;
@@ -1261,7 +1261,7 @@ int bp_bookmark_adaptor_get_ids_p
        // int count.
        int ids_count = bp_adaptor_ipc_read_int(sock);
        TRACE_DEBUG("response ids count:%d", ids_count);
-       if (ids_count < 256 && ids_count > 0) {
+       if (ids_count < BP_MAX_IDS_COUNT && ids_count > 0) {
                int *idlist = (int *)calloc(ids_count, sizeof(int));
                if (idlist == NULL) {
                        errorcode = BP_ERROR_OUT_OF_MEMORY;
index 6a00629fd95d1fbba2b79265f4a6d70b812a06b8..0f1b5c1030a8bc388396dc4b8a25e0baea9c612e 100755 (executable)
@@ -161,7 +161,7 @@ static int __bp_bookmark_csc_get_ids_p
        // int count.
        int ids_count = bp_adaptor_ipc_read_int(sock);
        TRACE_DEBUG("response ids count:%d", ids_count);
-       if(ids_count >= 256 || ids_count <= 0) {
+       if(ids_count >= BP_MAX_IDS_COUNT || ids_count <= 0) {
            pthread_mutex_unlock(&g_adaptor_mutex);
            return -1;
        } else {
@@ -263,7 +263,7 @@ int __bp_bookmark_csc_get_retrieved_ids_p
        // int count.
        int ids_count = bp_adaptor_ipc_read_int(sock);
        TRACE_DEBUG("response ids count:%d", ids_count);
-       if (ids_count < 256 && ids_count > 0) {
+       if (ids_count < BP_MAX_IDS_COUNT && ids_count > 0) {
                int *idlist = (int *)calloc(ids_count, sizeof(int));
                if (idlist == NULL) {
                        errorcode = BP_ERROR_OUT_OF_MEMORY;
index 8a3a365b6ad9f142dbccde95134ed8aa469f5dd0..95539d5ce343fec7fbcd243b3a8cab3a47071edb 100755 (executable)
@@ -276,7 +276,7 @@ int bp_common_adaptor_get_ids_p(const int sock, bp_command_fmt *cmd,
        // int count.
        int ids_count = bp_adaptor_ipc_read_int(sock);
        TRACE_DEBUG("response ids count:%d", ids_count);
-       if (ids_count < 256 && ids_count > 0) {
+       if (ids_count < BP_MAX_IDS_COUNT && ids_count > 0) {
                idlist = (int *)calloc(ids_count, sizeof(int));
                if (idlist == NULL) {
                        TRACE_ERROR("[CRITICAL] allocation");
@@ -293,8 +293,12 @@ int bp_common_adaptor_get_ids_p(const int sock, bp_command_fmt *cmd,
                        return -1;
                }
                *ids = idlist;
+                    return ids_count;
        }
-       return ids_count;
+        else if (ids_count >= BP_MAX_IDS_COUNT) {
+            TRACE_DEBUG("Count exceeded [%d]", ids_count);
+            return -1;
+        }
 }
 
 int bp_common_adaptor_get_string(const int sock, bp_command_fmt *cmd,
index 93178dc19fb527fe60fe78db42993a0046841fa4..f574eba3677ed69df9df2e7153b9a79232ea9a03 100755 (executable)
@@ -105,6 +105,8 @@ int bp_common_adaptor_clear_read_buffer(int sock, size_t length);
        }\
 } while(0)
 
+#define BP_MAX_IDS_COUNT 512
+
 #define BP_CHECK_IPC_SOCK (g_adaptorinfo == NULL ? -1 : g_adaptorinfo->cmd_socket)
 
 #define BP_PRINT_ERROR(id, errorcode) bp_common_print_errorcode(__FUNCTION__, __LINE__, id, errorcode)
index b975335bc35a98034b36bf3aa86dcdc333f2cebe..c184cbf9f676e43c0f5a12ff1a7e613b1e99fcfc 100755 (executable)
@@ -867,7 +867,7 @@ static int __bp_history_adaptor_get_cond_ids_p
        // int count.
        int ids_count = bp_adaptor_ipc_read_int(sock);
        TRACE_ERROR("response ids count:%d", ids_count);
-       if (ids_count < 256 && ids_count > 0) {
+       if (ids_count < BP_MAX_IDS_COUNT && ids_count > 0) {
                int *idlist = (int *)calloc(ids_count, sizeof(int));
                if (idlist == NULL) {
                        errorcode = BP_ERROR_OUT_OF_MEMORY;
@@ -998,7 +998,7 @@ int bp_history_adaptor_get_timestamp_ids_p
        // int count.
        int ids_count = bp_adaptor_ipc_read_int(sock);
        TRACE_DEBUG("response ids count:%d", ids_count);
-       if (ids_count < 256 && ids_count > 0) {
+       if (ids_count < BP_MAX_IDS_COUNT && ids_count > 0) {
                int *idlist = (int *)calloc(ids_count, sizeof(int));
                if (idlist == NULL) {
                        errorcode = BP_ERROR_OUT_OF_MEMORY;
index 005b80551ee32bfa6351aacd4a1fd21685fd950f..386b18fb2370991eedf373d2827d91f267861c44 100755 (executable)
@@ -1115,7 +1115,7 @@ int bp_tab_adaptor_get_duplicated_ids_p
        // int count.
        int ids_count = bp_adaptor_ipc_read_int(sock);
        TRACE_DEBUG("response ids count:%d", ids_count);
-       if (ids_count < 256 && ids_count > 0) {
+       if (ids_count < BP_MAX_IDS_COUNT&& ids_count > 0) {
                int *idlist = (int *)calloc(ids_count, sizeof(int));
                if (idlist == NULL) {
                        errorcode = BP_ERROR_OUT_OF_MEMORY;