summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHyunho Kang <hhstark.kang@samsung.com>2016-11-16 17:24:36 +0900
committerHyunho Kang <hhstark.kang@samsung.com>2016-11-16 17:52:46 +0900
commit7f2798a793b2083fddf8d68de00c7fedf992309e (patch)
tree89e4af93132131b0018fa4ef2efd473d0b683b09
parent0c406c420f694edb4d2b6000bbc97cc11f11198d (diff)
downloadmessage-port-7f2798a793b2083fddf8d68de00c7fedf992309e.tar.gz
message-port-7f2798a793b2083fddf8d68de00c7fedf992309e.tar.bz2
message-port-7f2798a793b2083fddf8d68de00c7fedf992309e.zip
Read sequence could be resembled when multi thread send message concurrently. Change-Id: Iaf45e86cb347f017417ec6023db5a2d761dd8099 Signed-off-by: Hyunho Kang <hhstark.kang@samsung.com>
-rw-r--r--src/message_port.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/src/message_port.c b/src/message_port.c
index 971e829..459bfe5 100644
--- a/src/message_port.c
+++ b/src/message_port.c
@@ -186,24 +186,39 @@ int message_port_check_trusted_remote_port(const char *remote_app_id, const char
int message_port_send_message(const char *remote_app_id, const char *remote_port, bundle *message)
{
+ int ret;
if (remote_app_id == NULL || remote_port == NULL || message == NULL) {
_LOGE("[MESSAGE_PORT_ERROR_INVALID_PARAMETER] NULL value is not allowed.");
return MESSAGE_PORT_ERROR_INVALID_PARAMETER;
}
- return convert_to_tizen_error((messageport_error_e)messageport_send_message(remote_app_id, remote_port, message));
+
+ _SECURE_LOGI("Send a message to (%s):(%s).", remote_app_id, remote_port);
+ pthread_mutex_lock(&__mutex);
+ ret = messageport_send_message(remote_app_id, remote_port, message);
+ pthread_mutex_unlock(&__mutex);
+
+ return convert_to_tizen_error((messageport_error_e)ret);
}
int message_port_send_trusted_message(const char *remote_app_id, const char *remote_port, bundle *message)
{
+ int ret;
if (remote_app_id == NULL || remote_port == NULL || message == NULL) {
_LOGE("[MESSAGE_PORT_ERROR_INVALID_PARAMETER] NULL value is not allowed.");
return MESSAGE_PORT_ERROR_INVALID_PARAMETER;
}
- return convert_to_tizen_error((messageport_error_e)messageport_send_trusted_message(remote_app_id, remote_port, message));
+ _SECURE_LOGI("Send a trusted message to (%s):(%s).", remote_app_id, remote_port);
+
+ pthread_mutex_lock(&__mutex);
+ ret = messageport_send_trusted_message(remote_app_id, remote_port, message);
+ pthread_mutex_unlock(&__mutex);
+
+ return convert_to_tizen_error((messageport_error_e)ret);
}
int message_port_send_message_with_local_port(const char *remote_app_id, const char *remote_port, bundle *message, int local_port_id)
{
+ int ret;
if (remote_app_id == NULL || remote_port == NULL || message == NULL) {
_LOGE("[MESSAGE_PORT_ERROR_INVALID_PARAMETER] NULL value is not allowed.");
return MESSAGE_PORT_ERROR_INVALID_PARAMETER;
@@ -229,11 +244,16 @@ int message_port_send_message_with_local_port(const char *remote_app_id, const c
}
_SECURE_LOGI("Send a message to (%s):(%s) and listen at the local port ID (%d).", remote_app_id, remote_port, local_port_id);
- return convert_to_tizen_error((messageport_error_e)messageport_send_bidirectional_message(local_port_id, remote_app_id, remote_port, message));
+ pthread_mutex_lock(&__mutex);
+ ret = messageport_send_bidirectional_message(local_port_id, remote_app_id, remote_port, message);
+ pthread_mutex_unlock(&__mutex);
+
+ return convert_to_tizen_error((messageport_error_e)ret);
}
int message_port_send_trusted_message_with_local_port(const char *remote_app_id, const char *remote_port, bundle *message, int local_port_id)
{
+ int ret;
if (remote_app_id == NULL || remote_port == NULL || message == NULL) {
_LOGE("[MESSAGE_PORT_ERROR_INVALID_PARAMETER] NULL value is not allowed.");
return MESSAGE_PORT_ERROR_INVALID_PARAMETER;
@@ -257,6 +277,10 @@ int message_port_send_trusted_message_with_local_port(const char *remote_app_id,
}
_SECURE_LOGI("Send a trusted message to (%s):(%s) and listen at the local port ID (%d).", remote_app_id, remote_port, local_port_id);
- return convert_to_tizen_error((messageport_error_e)messageport_send_bidirectional_trusted_message(local_port_id, remote_app_id, remote_port, message));
+ pthread_mutex_lock(&__mutex);
+ ret = messageport_send_bidirectional_trusted_message(local_port_id, remote_app_id, remote_port, message);
+ pthread_mutex_unlock(&__mutex);
+
+ return convert_to_tizen_error((messageport_error_e)ret);
}