summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDonghee Ye <donghee.ye@samsung.com>2013-05-16 00:27:18 +0900
committerDonghee Ye <donghee.ye@samsung.com>2013-05-16 01:16:54 +0900
commit97837e05a21f33e080a5be27a7283543592a433a (patch)
tree21726df26103b9a0e86b285ccfa7b6176b0263f3
parentcb137a63a04ccbdc0bf4e4b8e89525126ea22185 (diff)
downloadcontacts-service-tizen_2.1.tar.gz
contacts-service-tizen_2.1.tar.bz2
contacts-service-tizen_2.1.zip
Change-Id: I450aa2f1e5b368da634753ca046a542f13c4e884
-rwxr-xr-xCMakeLists.txt2
-rw-r--r--contacts-service2.manifest2
-rwxr-xr-xnative/ctsvc_sqlite.c73
-rw-r--r--packaging/contacts-service.spec2
4 files changed, 69 insertions, 10 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b26c0c4..90c0343 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -13,7 +13,7 @@ SET(PREFIX ${CMAKE_INSTALL_PREFIX})
SET(EXEC_PREFIX "\${prefix}")
SET(INCLUDEDIR "\${prefix}/${DEST_INCLUDE_DIR}")
SET(VERSION_MAJOR 0)
-SET(VERSION "${VERSION_MAJOR}.9.84.1")
+SET(VERSION "${VERSION_MAJOR}.9.84.2")
EXECUTE_PROCESS(COMMAND build-util/generator.sh)
diff --git a/contacts-service2.manifest b/contacts-service2.manifest
index 7afaf3a..1f55882 100644
--- a/contacts-service2.manifest
+++ b/contacts-service2.manifest
@@ -14,7 +14,7 @@
</request>
</define>
<assign>
- <filesystem path="/usr/lib/libcontacts-service2.so.0.9.84.1" label="_"/>
+ <filesystem path="/usr/lib/libcontacts-service2.so.0.9.84.2" label="_"/>
<filesystem path="/usr/lib/libcontacts-service2.so.0" label="_"/>
<filesystem path="/opt/usr/dbspace/.contacts-svc.db" label="contacts-service::db"/>
<filesystem path="/opt/usr/dbspace/.contacts-svc.db-journal" label="contacts-service::db"/>
diff --git a/native/ctsvc_sqlite.c b/native/ctsvc_sqlite.c
index e511911..fc912f8 100755
--- a/native/ctsvc_sqlite.c
+++ b/native/ctsvc_sqlite.c
@@ -38,6 +38,8 @@
#include "ctsvc_phonelog.h"
#include "ctsvc_person.h"
+#define CTSVC_QUERY_RETRY_TIME 2
+
static __thread sqlite3 *ctsvc_db = NULL;
static inline int __ctsvc_db_busyhandler(void *pData, int count)
@@ -135,14 +137,52 @@ int cts_db_get_next_id(const char *table) {
int ctsvc_query_get_first_int_result(const char *query, int *result) {
int ret;
+ struct timeval from, now, diff;
+ bool retry = false;
cts_stmt stmt = NULL;
RETVM_IF(NULL == ctsvc_db, CONTACTS_ERROR_DB /*CTS_ERR_DB_NOT_OPENED*/, "DB error : Database is not opended");
- ret = sqlite3_prepare_v2(ctsvc_db, query, strlen(query), &stmt, NULL);
- RETVM_IF(SQLITE_OK != ret, CONTACTS_ERROR_DB,
- "DB error : sqlite3_prepare_v2(%s) Failed(%s)", query, sqlite3_errmsg(ctsvc_db));
+ gettimeofday(&from, NULL);
+ do {
+ ret = sqlite3_prepare_v2(ctsvc_db, query, strlen(query), &stmt, NULL);
+
+ if (ret != SQLITE_OK)
+ CTS_ERR("DB error : sqlite3_prepare_v2() Failed(%d, %s)", ret, sqlite3_errmsg(ctsvc_db));
+
+ if (ret == SQLITE_BUSY || ret == SQLITE_LOCKED) {
+ gettimeofday(&now, NULL);
+ timersub(&now, &from, &diff);
+ retry = (diff.tv_sec < CTSVC_QUERY_RETRY_TIME)? true:false;
+ if (retry)
+ usleep(50*1000); // 50 ms
+ } else
+ retry = false;
+ }while(retry);
+
+ if (SQLITE_OK != ret) {
+ CTS_ERR("DB error : sqlite3_prepare_v2(%s) Failed(%s)", query, sqlite3_errmsg(ctsvc_db));
+ return CONTACTS_ERROR_DB;
+ }
+
+ retry = false;
+ gettimeofday(&from, NULL);
+ do {
+ ret = sqlite3_step(stmt);
+
+ if (ret != SQLITE_ROW)
+ CTS_ERR("DB error : sqlite3_step() Failed(%d, %s)", ret, sqlite3_errmsg(ctsvc_db));
+
+ if (ret == SQLITE_BUSY || ret == SQLITE_LOCKED) {
+ gettimeofday(&now, NULL);
+ timersub(&now, &from, &diff);
+ retry = (diff.tv_sec < CTSVC_QUERY_RETRY_TIME)? true:false;
+ if (retry)
+ usleep(50*1000); // 50 ms
+ }
+ else
+ retry = false;
+ }while(retry);
- ret = sqlite3_step(stmt);
if (SQLITE_ROW != ret) {
sqlite3_finalize(stmt);
CTS_DBG("query : %s", query);
@@ -163,12 +203,31 @@ int ctsvc_query_get_first_int_result(const char *query, int *result) {
int ctsvc_query_exec(const char *query) {
int ret;
+ struct timeval from, now, diff;
+ bool retry = false;
char *err_msg = NULL;
RETVM_IF(NULL == ctsvc_db, CONTACTS_ERROR_DB /*CTS_ERR_DB_NOT_OPENED*/, "DB error : Database is not opended");
CTS_DBG("query : %s", query);
- ret = sqlite3_exec(ctsvc_db, query, NULL, NULL, &err_msg);
+ gettimeofday(&from, NULL);
+ do {
+ ret = sqlite3_exec(ctsvc_db, query, NULL, NULL, &err_msg);
+
+ if (ret != SQLITE_OK)
+ CTS_ERR("DB error : sqlite3_exec() Failed(%d, %s)", ret, sqlite3_errmsg(ctsvc_db));
+
+ if (ret == SQLITE_BUSY || ret == SQLITE_LOCKED) {
+ gettimeofday(&now, NULL);
+ timersub(&now, &from, &diff);
+ retry = (diff.tv_sec < CTSVC_QUERY_RETRY_TIME)? true:false;
+ if (retry)
+ usleep(50*1000); // 50 ms
+ }
+ else
+ retry = false;
+ } while(retry);
+
if (SQLITE_OK != ret) {
CTS_ERR("sqlite3_exec(%s) Failed(%d, %s)", query, ret, err_msg);
sqlite3_free(err_msg);
@@ -207,7 +266,7 @@ cts_stmt cts_query_prepare(char *query) {
if (ret == SQLITE_BUSY || ret == SQLITE_LOCKED) {
gettimeofday(&now, NULL);
timersub(&now, &from, &diff);
- retry = (diff.tv_sec < 2)? true:false; // retry it during 2 second
+ retry = (diff.tv_sec < CTSVC_QUERY_RETRY_TIME)? true:false;
if (retry)
usleep(50*1000); // 50 ms
} else
@@ -251,7 +310,7 @@ int cts_stmt_step(cts_stmt stmt) {
if (ret == SQLITE_BUSY || ret == SQLITE_LOCKED) {
gettimeofday(&now, NULL);
timersub(&now, &from, &diff);
- retry = (diff.tv_sec < 1)? true:false; // retry it during 1 second
+ retry = (diff.tv_sec < CTSVC_QUERY_RETRY_TIME)? true:false;
if (retry)
usleep(50*1000); // 50 ms
}
diff --git a/packaging/contacts-service.spec b/packaging/contacts-service.spec
index 06bc589..7ec2c5e 100644
--- a/packaging/contacts-service.spec
+++ b/packaging/contacts-service.spec
@@ -1,6 +1,6 @@
Name: contacts-service
Summary: Contacts Service
-Version: 0.9.84.1
+Version: 0.9.84.2
Release: 1
Group: TO_BE/FILLED_IN
License: Apache-2.0