summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyeonghun Lee <kh9090.lee@samsung.com>2016-12-05 17:04:59 +0900
committerKyeonghun Lee <kh9090.lee@samsung.com>2016-12-06 15:14:51 +0900
commit400fe8099cbe736a5b7df91a2fba9df0fa89e8e7 (patch)
treea30a370d38dfb9c2a9c4be5fa044001ccdb74ad7
parentd967d54ec9a0381e72a2a35f92fa0d3cdb65b6a6 (diff)
downloadmsg-service-400fe8099cbe736a5b7df91a2fba9df0fa89e8e7.tar.gz
msg-service-400fe8099cbe736a5b7df91a2fba9df0fa89e8e7.tar.bz2
msg-service-400fe8099cbe736a5b7df91a2fba9df0fa89e8e7.zip
[TSAM-9946] msg-service socket buffer size issue fixed(temporal)
Change-Id: Ib29c3d40bae9e67e6a80a73178f7bc20a389cf1c Signed-off-by: Kyeonghun Lee <kh9090.lee@samsung.com>
-rwxr-xr-xframework/storage-handler/MsgStorageMessage.cpp6
-rwxr-xr-xframework/transaction-manager/MsgTransManager.cpp24
-rwxr-xr-xinclude/proxy/MsgProxyListener.h1
-rwxr-xr-xinclude/utils/MsgIpcSocket.h3
-rwxr-xr-xplugin/sms_plugin/SmsPluginStorage.cpp2
-rwxr-xr-xproxy/MsgProxyListener.cpp30
-rwxr-xr-xutils/MsgIpcSocket.cpp65
7 files changed, 114 insertions, 17 deletions
diff --git a/framework/storage-handler/MsgStorageMessage.cpp b/framework/storage-handler/MsgStorageMessage.cpp
index cf67fc7..bbb72e4 100755
--- a/framework/storage-handler/MsgStorageMessage.cpp
+++ b/framework/storage-handler/MsgStorageMessage.cpp
@@ -1018,6 +1018,8 @@ msg_error_t MsgStoDeleteMessage(msg_message_id_t msgId, bool bCheckIndication)
/* Update Thread Callback */
if (bCheckIndication == true && MsgExistConversation(dbHandle, convId) == true && MsgExistInThreadViewList(dbHandle, convId) == true)
MsgTransactionManager::instance()->broadcastThreadChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_UPDATE, convId);
+ else if (bCheckIndication == true)
+ MsgTransactionManager::instance()->broadcastThreadChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_DELETE, convId);
if (msgType.mainType == MSG_SMS_TYPE && folderId == MSG_INBOX_ID) {
msgType.classType = MSG_CLASS_NONE;
@@ -1318,6 +1320,8 @@ msg_error_t MsgStoDeleteAllMessageInFolder(msg_folder_id_t folderId, bool bOnlyD
msg_thread_id_t cur_thread_id = threadList2.front();
if (MsgExistConversation(dbHandle, cur_thread_id) == true && MsgExistInThreadViewList(dbHandle, cur_thread_id) == true)
MsgTransactionManager::instance()->broadcastThreadChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_UPDATE, cur_thread_id);
+ else
+ MsgTransactionManager::instance()->broadcastThreadChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_DELETE, cur_thread_id);
threadList2.pop();
}
@@ -1683,6 +1687,8 @@ msg_error_t MsgStoDeleteMessageByList(msg_id_list_s *pMsgIdList)
msg_thread_id_t cur_thread_id = threadList3.front();
if (MsgExistConversation(dbHandle, cur_thread_id) == true && MsgExistInThreadViewList(dbHandle, cur_thread_id) == true)
MsgTransactionManager::instance()->broadcastThreadChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_UPDATE, cur_thread_id);
+ else
+ MsgTransactionManager::instance()->broadcastThreadChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_DELETE, cur_thread_id);
threadList3.pop();
}
diff --git a/framework/transaction-manager/MsgTransManager.cpp b/framework/transaction-manager/MsgTransManager.cpp
index ff9ac7b..2e189f8 100755
--- a/framework/transaction-manager/MsgTransManager.cpp
+++ b/framework/transaction-manager/MsgTransManager.cpp
@@ -100,6 +100,7 @@ MsgTransactionManager::MsgTransactionManager() : running(false), mx(), mxQ(), cv
javaMMSList.clear();
operationSyncMLMsgCBList.clear();
storageChangeFdMap.clear();
+ threadChangeFdMap.clear();
handlerMap.clear();
@@ -147,6 +148,7 @@ MsgTransactionManager::MsgTransactionManager() : running(false), mx(), mxQ(), cv
handlerMap[MSG_CMD_PLG_SENT_STATUS_CNF] = &MsgSentStatusHandler;
handlerMap[MSG_CMD_PLG_STORAGE_CHANGE_IND] = &MsgStorageChangeHandler;
+ handlerMap[MSG_CMD_PLG_THREAD_CHANGE_IND] = &MsgThreadChangeHandler;
handlerMap[MSG_CMD_PLG_INCOMING_MSG_IND] = &MsgIncomingMsgHandler;
handlerMap[MSG_CMD_PLG_INCOMING_MMS_CONF] = &MsgIncomingMMSConfMsgHandler;
handlerMap[MSG_CMD_PLG_INCOMING_PUSH_IND] = &MsgIncomingPushMsgHandler;
@@ -430,6 +432,7 @@ void MsgTransactionManager::handleRequest(int fd)
switch (pCmd->cmdType) {
case MSG_CMD_PLG_SENT_STATUS_CNF:
case MSG_CMD_PLG_STORAGE_CHANGE_IND:
+ case MSG_CMD_PLG_THREAD_CHANGE_IND:
case MSG_CMD_PLG_INCOMING_MSG_IND:
case MSG_CMD_PLG_INCOMING_MMS_CONF:
case MSG_CMD_PLG_INCOMING_SYNCML_IND:
@@ -596,6 +599,14 @@ void MsgTransactionManager::cleanup(int fd)
for (; it != storageChangeFdMap.end(); ++it)
MSG_DEBUG("[%d]", it->first);
+ /* remove thread change callback for fd */
+ threadChangeFdMap.erase(fd);
+
+ MSG_DEBUG("After erase fd [%d], threadChangeFdMap has below.", fd);
+ it = threadChangeFdMap.begin();
+ for (; it != threadChangeFdMap.end(); ++it)
+ MSG_DEBUG("[%d]", it->first);
+
/* remove report msg incoming callback for fd */
reportMsgCBFdMap.erase(fd);
@@ -1290,16 +1301,6 @@ void MsgTransactionManager::broadcastStorageChangeCB(const msg_error_t err, cons
updatedConvQ.push_back(conv_id);
}
}
- } else if (storageChangeType == MSG_STORAGE_CHANGE_DELETE) {
- std::list<msg_thread_id_t>::iterator it = cur_conv_list.begin();
- for (; it != cur_conv_list.end(); ) {
- if (MsgExistConversation(dbHandle, *it) == false || MsgExistInThreadViewList(dbHandle, *it) == false) {
- broadcastThreadChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_DELETE, *it);
- it = cur_conv_list.erase(it);
- } else{
- it++;
- }
- }
}
updatedConvQ.clear();
@@ -1314,6 +1315,9 @@ void MsgTransactionManager::broadcastThreadChangeCB(const msg_error_t err, const
MSG_DEBUG("storageChangeType [%d], threadId [%d]", storageChangeType, threadId);
+ if (storageChangeType == MSG_STORAGE_CHANGE_DELETE)
+ cur_conv_list.remove(threadId);
+
int dataSize = 0;
char* pEventData = NULL;
diff --git a/include/proxy/MsgProxyListener.h b/include/proxy/MsgProxyListener.h
index 6cf9dc8..b15e5d3 100755
--- a/include/proxy/MsgProxyListener.h
+++ b/include/proxy/MsgProxyListener.h
@@ -191,7 +191,6 @@ private:
MsgIpcClientSocket cliSock;
MsgMutex mx;
- MsgCndVar cv;
MsgSentStatusCBList sentStatusCBList;
MsgNewMessageCBList newMessageCBList;
diff --git a/include/utils/MsgIpcSocket.h b/include/utils/MsgIpcSocket.h
index f230c08..f8dd0af 100755
--- a/include/utils/MsgIpcSocket.h
+++ b/include/utils/MsgIpcSocket.h
@@ -33,6 +33,9 @@
#define MSG_MAX_IPC_SIZE 50000 /* 50 * 1000 = sizeof(msg common info) * max message count */
#define MAX_NUM_IPC_CLIENT 10
+#define MAX_BUFFER_PATH "proc/sys/net/core/wmem_max"
+#define DEFAULT_MAX_BUFFER_SIZE 2097152
+
#define MSG_SOCKET_PATH "/tmp/.msgfw_socket"
#define CUSTOM_SOCKET_ERROR -1
diff --git a/plugin/sms_plugin/SmsPluginStorage.cpp b/plugin/sms_plugin/SmsPluginStorage.cpp
index 0bcbc50..9ed6a22 100755
--- a/plugin/sms_plugin/SmsPluginStorage.cpp
+++ b/plugin/sms_plugin/SmsPluginStorage.cpp
@@ -644,6 +644,8 @@ msg_error_t SmsPluginStorage::deleteSmsMessage(msg_message_id_t msgId)
if (dbHandle->stepQuery() == MSG_ERR_DB_ROW)
SmsPluginEventHandler::instance()->callbackThreadChange(MSG_STORAGE_CHANGE_UPDATE, convId);
+ else
+ SmsPluginEventHandler::instance()->callbackThreadChange(MSG_STORAGE_CHANGE_DELETE, convId);
dbHandle->finalizeQuery();
diff --git a/proxy/MsgProxyListener.cpp b/proxy/MsgProxyListener.cpp
index 8d834c9..b4775e0 100755
--- a/proxy/MsgProxyListener.cpp
+++ b/proxy/MsgProxyListener.cpp
@@ -161,8 +161,6 @@ void MsgProxyListener::start(MsgHandle* pMsgHandle)
if (running == 0) {
cliSock.connect(MSG_SOCKET_PATH);
- /* wake up the waiting thread */
- cv.signal();
int fd = cliSock.fd();
@@ -654,6 +652,19 @@ void MsgProxyListener::clearListOfClosedHandle(MsgHandle* pMsgHandle)
}
}
+
+ /* Thread change Message CB list */
+ std::list<MSG_THREAD_CHANGE_CB_ITEM_S>::iterator it11 = threadChangeCBList.begin();
+
+ for (; it11 != threadChangeCBList.end(); ) {
+ if (it11->hAddr == pMsgHandle) {
+ threadChangeCBList.erase(it11++);
+ stop();
+ } else {
+ ++it11;
+ }
+ }
+
/* Open Handle Set */
openHandleSet.erase(pMsgHandle);
@@ -797,6 +808,19 @@ void MsgProxyListener::refreshListOfOpenedHandle(MsgHandle* pMsgHandle)
}
}
+ /* Thread change Message CB list */
+ std::list<MSG_THREAD_CHANGE_CB_ITEM_S>::iterator it11 = threadChangeCBList.begin();
+ for (; it11 != threadChangeCBList.end(); ++it11) {
+ if (it11->hAddr == pMsgHandle) {
+ it11->fd = CUSTOM_SOCKET_ERROR;
+ try {
+ pMsgHandle->regThreadChangeCallback(it11->pfThreadChangeCB, it11->userParam);
+ } catch (MsgException& e) {
+ MSG_FATAL("%s", e.what());
+ }
+ }
+ }
+
MSG_END();
}
@@ -1305,8 +1329,8 @@ void MsgProxyListener::clearProxyCBLists()
newLBSMessageCBList.clear();
newPushMessageCBList.clear();
newCBMessageCBList.clear();
- newSyncMLMessageCBList.clear();
storageChangeCBList.clear();
+ threadChangeCBList.clear();
reportMessageCBList.clear();
}
diff --git a/utils/MsgIpcSocket.cpp b/utils/MsgIpcSocket.cpp
index b34ea2b..a24eb37 100755
--- a/utils/MsgIpcSocket.cpp
+++ b/utils/MsgIpcSocket.cpp
@@ -28,6 +28,7 @@
#include "MsgDebug.h"
#include "MsgException.h"
#include "MsgIpcSocket.h"
+#include "MsgUtilFile.h"
/*==================================================================================================
IMPLEMENTATION OF MsgIpcClientSocket - Member Functions
@@ -176,7 +177,7 @@ int MsgIpcClientSocket::write(const char* buf, unsigned int len)
return len;
}
-int MsgIpcClientSocket::readn(char *buf, unsigned int len )
+int MsgIpcClientSocket::readn(char *buf, unsigned int len)
{
unsigned int nleft;
int nread;
@@ -430,7 +431,7 @@ void MsgIpcServerSocket::close(int fd)
MSG_END();
}
-int MsgIpcServerSocket::readn(int fd, char *buf, unsigned int len )
+int MsgIpcServerSocket::readn(int fd, char *buf, unsigned int len)
{
size_t nleft;
int nread;
@@ -455,7 +456,7 @@ int MsgIpcServerSocket::readn(int fd, char *buf, unsigned int len )
return (len-nleft);
}
-int MsgIpcServerSocket::read(int fd, char** buf, int* len )
+int MsgIpcServerSocket::read(int fd, char** buf, int* len)
{
if (sockfd == CUSTOM_SOCKET_ERROR) {
MSG_FATAL("server_socket(%p) is not initd %d", &sockfd, sockfd);
@@ -503,6 +504,58 @@ int MsgIpcServerSocket::read(int fd, char** buf, int* len )
return n;
}
+void _get_max_buffer_size(int *max_buffer_size)
+{
+ if (MsgAccessFile(MAX_BUFFER_PATH, R_OK) == false) {
+ *max_buffer_size = DEFAULT_MAX_BUFFER_SIZE;
+ return;
+ }
+
+ FILE *pFile = MsgOpenFile(MAX_BUFFER_PATH, "rb");
+ if (pFile == NULL) {
+ *max_buffer_size = DEFAULT_MAX_BUFFER_SIZE;
+ return;
+ }
+
+ if (fscanf(pFile, "%d", max_buffer_size) < 0) {
+ *max_buffer_size = DEFAULT_MAX_BUFFER_SIZE;
+ }
+
+ MsgCloseFile(pFile);
+}
+
+bool _doubling_buffer_size(int sock)
+{
+ int bSize = 0;
+ socklen_t rn = (socklen_t)sizeof(int);
+ static int max_buffer_size = -1;
+
+ int result = getsockopt(sock, SOL_SOCKET, SO_SNDBUF, &bSize, &rn);
+ if (result < 0) {
+ MSG_ERR("getsockopt: %s", g_strerror(errno));
+ return false;
+ }
+
+ MSG_DEBUG("send buffer size %d", bSize);
+
+ if (max_buffer_size < 0)
+ _get_max_buffer_size(&max_buffer_size);
+
+ MSG_DEBUG("current buffer size [%d] max buffer size [%d]", bSize, max_buffer_size);
+
+ if (bSize * 2 > max_buffer_size)
+ return false;
+
+ bSize *= 2;
+ result = setsockopt(sock, SOL_SOCKET, SO_SNDBUF, &bSize, rn);
+ if (result < 0) {
+ MSG_ERR("setsockopt: %s", g_strerror(errno));
+ return false;
+ }
+
+ return true;
+}
+
int MsgIpcServerSocket::writen(int fd, const char *buf, unsigned int len)
{
unsigned int nleft;
@@ -517,6 +570,12 @@ int MsgIpcServerSocket::writen(int fd, const char *buf, unsigned int len)
if (nwrite < 0) {
MSG_FATAL("write: %s", g_strerror(errno));
+ if (errno == EINTR) {
+ continue;
+ } else if (errno == EAGAIN) {
+ if (_doubling_buffer_size(fd) == true)
+ continue;
+ }
return nwrite;
} else if (nwrite == 0) { /* Nothing is send. */
break;