fix msg-server boot timing issue 27/91727/4 accepted/tizen/ivi/20161011.234054 accepted/tizen/mobile/20161011.234050 accepted/tizen/wearable/20161011.234044 submit/tizen/20161011.042615
authorKyeonghun Lee <kh9090.lee@samsung.com>
Tue, 11 Oct 2016 05:33:38 +0000 (14:33 +0900)
committerKyeonghun Lee <kh9090.lee@samsung.com>
Tue, 11 Oct 2016 05:58:41 +0000 (14:58 +0900)
Change-Id: I4e6827b8942fe562dc456ef057467fcdc92e23ff
Signed-off-by: Kyeonghun Lee <kh9090.lee@samsung.com>
framework/storage-handler/MsgStorageManager.cpp
packaging/msg-server.service
utils/MsgSqliteWrapper.cpp

index 16d6505..6acf115 100755 (executable)
@@ -34,6 +34,7 @@
 #include "MsgPluginManager.h"
 #include "MsgStorageHandler.h"
 
+#define MSG_DB_ACCESS_MAX_COUNT 10
 #define MSG_DB_VERSION 2
 
 /*==================================================================================================
@@ -142,6 +143,21 @@ void MsgStoUpdateDBVersion()
 msg_error_t MsgStoDBVerCheck()
 {
        MsgDbHandler *dbHandle = getDbHandle();
+#if 1 /* TODO: need to improve this code later */
+       int cnt = MSG_DB_ACCESS_MAX_COUNT;
+       while (cnt--) {
+               if (dbHandle->connect() == MSG_SUCCESS)
+                       break;
+
+               if (cnt == 0) {
+                       MSG_ERR("db connect try count over %d", MSG_DB_ACCESS_MAX_COUNT);
+                       return MSG_ERR_DB_CONNECT;
+               }
+
+               MSG_DEBUG("waiting for mount /opt/usr/ cnt [%d]", cnt);
+               sleep(1);
+       }
+#endif
        int dbVersion = 0;
 
        char sqlQuery[MAX_QUERY_LEN+1];
index 7b764b2..127f111 100755 (executable)
@@ -1,6 +1,6 @@
 [Unit]
 Description=Message server
-After=contacts-service.service lazy_mount.service
+After=contacts-service.service lazy_mount.service systemd-logind.service
 
 [Service]
 Type=simple
index 21cb34a..1f66b23 100755 (executable)
@@ -80,9 +80,11 @@ msg_error_t MsgDbHandler::connect()
                        return MSG_SUCCESS;
                } else if (ret == SQLITE_PERM){
                        MSG_DEBUG("DB Connect Fail [%d]", ret);
+                       disconnect();
                        return MSG_ERR_PERMISSION_DENIED;
                } else {
                        MSG_DEBUG("DB Connect Fail [%d]", ret);
+                       disconnect();
                        return MSG_ERR_DB_CONNECT;
                }
        } else {