Fix svace issue(WGID 379871)
[platform/core/telephony/tel-plugin-database.git] / src / database_main.c
index 9756a3d..4a23f7c 100644 (file)
 #define PLUGIN_VERSION 1
 #endif
 
+#define BUSY_WAITING_USEC 50000 /* 0.05 sec */
+#define BUSY_WAITING_MAX 20 /* wait for max 1 sec */
+
+
 static gboolean __update_query_database(Storage *strg, void *handle, const char *query, GHashTable *in_param)
 {
        int rv = 0;
@@ -95,14 +99,13 @@ static gboolean __update_query_database(Storage *strg, void *handle, const char
 
 static int _busy_handler(void *pData, int count)
 {
-       if (5 - count > 0) {
-               dbg("Busy Handler Called! : CNT(%d)\n", count + 1);
-               usleep((count + 1) * 100000);
+        if (count < BUSY_WAITING_MAX) {
+               usleep(BUSY_WAITING_USEC);
                return 1;
-       } else {
-               dbg("Busy Handler will be returned SQLITE_BUSY error\n");
-               return 0;
        }
+
+       dbg("Busy Handler will be returned SQLITE_BUSY error\n");
+       return 0;
 }
 
 static void *create_handle(Storage *strg, const char *path)