From 753270b3aed9a02fa975a3deaf8a34efe9bb03ab Mon Sep 17 00:00:00 2001 From: Jongkyu Koo Date: Tue, 16 Jan 2018 14:48:28 +0900 Subject: [PATCH] Modify to use phone_number_connect() for performance Change-Id: I990ebe18da3250102d7a404c949843db5c422141 Signed-off-by: Jongkyu Koo --- server/ctsvc_ipc_server.c | 3 +++ server/db/ctsvc_db_query.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/server/ctsvc_ipc_server.c b/server/ctsvc_ipc_server.c index e57afc8..c2536a3 100644 --- a/server/ctsvc_ipc_server.c +++ b/server/ctsvc_ipc_server.c @@ -1243,6 +1243,7 @@ void ctsvc_ipc_server_db_insert_records(pims_ipc_h ipc, pims_ipc_data_h indata, contacts_list_first(list); } + ctsvc_server_stop_timeout(); ret = ctsvc_db_insert_records(list, &ids, &id_count); if (outdata) { @@ -1387,6 +1388,7 @@ void ctsvc_ipc_server_db_update_records(pims_ipc_h ipc, pims_ipc_data_h indata, contacts_list_first(list); } + ctsvc_server_stop_timeout(); ret = ctsvc_db_update_records(list); if (outdata) { @@ -1668,6 +1670,7 @@ void ctsvc_ipc_server_db_replace_records(pims_ipc_h ipc, pims_ipc_data_h indata, contacts_list_first(list); } + ctsvc_server_stop_timeout(); ret = ctsvc_db_replace_records(list, ids, count); if (outdata) { diff --git a/server/db/ctsvc_db_query.c b/server/db/ctsvc_db_query.c index 64960a9..ff3efce 100644 --- a/server/db/ctsvc_db_query.c +++ b/server/db/ctsvc_db_query.c @@ -17,6 +17,7 @@ * */ #include +#include #include "contacts.h" #include "contacts_internal.h" @@ -3728,6 +3729,8 @@ static int __ctsvc_db_insert_records(contacts_list_h list, int **ids) contacts_list_first(list); index = 0; + /* for performance. phone_number_get_normalized_number() can be called repeatedly below */ + phone_number_connect(); do { ret = contacts_list_get_current_record_p(list, &record); if (CONTACTS_ERROR_NONE != ret) { @@ -3735,6 +3738,7 @@ static int __ctsvc_db_insert_records(contacts_list_h list, int **ids) ERR("contacts_list_get_current_record_p() Fail(%d)", ret); ctsvc_end_trans(false); free(id); + phone_number_disconnect(); return ret; /* LCOV_EXCL_STOP */ } @@ -3745,11 +3749,12 @@ static int __ctsvc_db_insert_records(contacts_list_h list, int **ids) ERR("contacts_db_insert_record() Fail(%d)", ret); ctsvc_end_trans(false); free(id); + phone_number_disconnect(); return ret; /* LCOV_EXCL_STOP */ } } while (CONTACTS_ERROR_NONE == contacts_list_next(list)); - + phone_number_disconnect(); ret = ctsvc_end_trans(true); if (ret < CONTACTS_ERROR_NONE) { /* LCOV_EXCL_START */ @@ -3814,12 +3819,15 @@ static int __ctsvc_db_update_records(contacts_list_h list) RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_begin_trans() Fail(%d)", ret); contacts_list_first(list); + /* for performance. phone_number_get_normalized_number() can be called repeatedly below */ + phone_number_connect(); do { ret = contacts_list_get_current_record_p(list, &record); if (CONTACTS_ERROR_NONE != ret) { /* LCOV_EXCL_START */ ERR("contacts_list_get_current_record_p() Fail(%d)", ret); ctsvc_end_trans(false); + phone_number_disconnect(); return ret; /* LCOV_EXCL_STOP */ } @@ -3829,10 +3837,12 @@ static int __ctsvc_db_update_records(contacts_list_h list) /* LCOV_EXCL_START */ ERR("contacts_db_update_record() Fail(%d)", ret); ctsvc_end_trans(false); + phone_number_disconnect(); return ret; /* LCOV_EXCL_STOP */ } } while (CONTACTS_ERROR_NONE == contacts_list_next(list)); + phone_number_disconnect(); ret = ctsvc_end_trans(true); if (ret < CONTACTS_ERROR_NONE) { /* LCOV_EXCL_START */ @@ -4789,12 +4799,15 @@ static int __ctsvc_db_replace_records(contacts_list_h list, int ids[], int count contacts_list_first(list); i = 0; + /* for performance. phone_number_get_normalized_number() can be called repeatedly below */ + phone_number_connect(); do { ret = contacts_list_get_current_record_p(list, &record); if (CONTACTS_ERROR_NONE != ret) { /* LCOV_EXCL_START */ ERR("contacts_list_get_current_record_p() Fail(%d)", ret); ctsvc_end_trans(false); + phone_number_disconnect(); return ret; /* LCOV_EXCL_STOP */ } @@ -4804,11 +4817,12 @@ static int __ctsvc_db_replace_records(contacts_list_h list, int ids[], int count /* LCOV_EXCL_START */ ERR("contacts_db_replace_record() Fail(%d)", ret); ctsvc_end_trans(false); + phone_number_disconnect(); return ret; /* LCOV_EXCL_STOP */ } } while (CONTACTS_ERROR_NONE == contacts_list_next(list)); - + phone_number_disconnect(); ret = ctsvc_end_trans(true); return ret; -- 2.7.4