Add mutex encapsulation
[platform/core/appfw/message-port.git] / src / message_port_common.c
index b025aa7..36fbad7 100755 (executable)
@@ -44,6 +44,7 @@ GDBusConnection *gdbus_conn;
 char *app_id;
 
 static const int MAX_MESSAGE_SIZE = 16 * 1024;
+static pthread_mutex_t _message_port_mutex = PTHREAD_MUTEX_INITIALIZER;
 
 int write_socket(int fd,
                const char *buffer,
@@ -353,3 +354,13 @@ char *get_encoded_name(const char *remote_app_id, const char *port_name, bool is
 
        return md5_interface;
 }
+
+void message_port_lock_mutex()
+{
+       pthread_mutex_lock(&_message_port_mutex);
+}
+
+void message_port_unlock_mutex()
+{
+       pthread_mutex_unlock(&_message_port_mutex);
+}