/* 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;
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();
}
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();
}
javaMMSList.clear();
operationSyncMLMsgCBList.clear();
storageChangeFdMap.clear();
+ threadChangeFdMap.clear();
handlerMap.clear();
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;
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:
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);
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();
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;
MsgIpcClientSocket cliSock;
MsgMutex mx;
- MsgCndVar cv;
MsgSentStatusCBList sentStatusCBList;
MsgNewMessageCBList newMessageCBList;
#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
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();
if (running == 0) {
cliSock.connect(MSG_SOCKET_PATH);
- /* wake up the waiting thread */
- cv.signal();
int fd = cliSock.fd();
}
}
+
+ /* 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);
}
}
+ /* 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();
}
newLBSMessageCBList.clear();
newPushMessageCBList.clear();
newCBMessageCBList.clear();
- newSyncMLMessageCBList.clear();
storageChangeCBList.clear();
+ threadChangeCBList.clear();
reportMessageCBList.clear();
}
#include "MsgDebug.h"
#include "MsgException.h"
#include "MsgIpcSocket.h"
+#include "MsgUtilFile.h"
/*==================================================================================================
IMPLEMENTATION OF MsgIpcClientSocket - Member Functions
return len;
}
-int MsgIpcClientSocket::readn(char *buf, unsigned int len )
+int MsgIpcClientSocket::readn(char *buf, unsigned int len)
{
unsigned int nleft;
int nread;
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;
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);
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;
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;