0.0.28-1 has been merged tizen_2.1 2.1b_release accepted/tizen_2.1/20130425.033123 submit/tizen_2.1/20130424.232844 submit/tizen_2.2/20130714.153355
authorJaepil Choi <jeffry82@samsung.com>
Mon, 22 Apr 2013 10:55:46 +0000 (19:55 +0900)
committerJaepil Choi <jeffry82@samsung.com>
Mon, 22 Apr 2013 10:55:46 +0000 (19:55 +0900)
Change-Id: I913b712dbece410675efb88c1919a5fc8a910ac8

18 files changed:
CMakeLists.txt
LICENSE.APLv2
NOTICE
include/pims-ipc-data.h
include/pims-ipc-svc.h
include/pims-ipc-types.h
include/pims-ipc.h
packaging/pims-ipc.spec
pims-ipc.manifest.in
src/pims-debug.h
src/pims-internal.h
src/pims-ipc-data.c
src/pims-ipc-svc.c
src/pims-ipc.c
src/pims-socket.c
src/pims-socket.h
test/sock-test.c
test/test.c

index 655c15f..5631d18 100755 (executable)
@@ -15,7 +15,7 @@ SET(EXEC_PREFIX "\${prefix}")
 
 SET(INCLUDEDIR "\${prefix}/${DEST_INCLUDE_DIR}")
 SET(VERSION_MAJOR 0)
-SET(VERSION "${VERSION_MAJOR}.0.1")
+SET(VERSION "${VERSION_MAJOR}.0.28")
 
 INCLUDE_DIRECTORIES(${SRC_INCLUDE_DIR})
 #SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -I${CMAKE_SOURCE_DIR}/src -I${SRC_INCLUDE_DIR} -D_NON_SLP")
index bae7f54..311e5ba 100644 (file)
@@ -1,4 +1,4 @@
-Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.\r
+Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.\r
 \r
                                  Apache License\r
                            Version 2.0, January 2004\r
diff --git a/NOTICE b/NOTICE
index 4c49449..d34af37 100644 (file)
--- a/NOTICE
+++ b/NOTICE
@@ -1 +1 @@
-Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
index e3bc131..5c8e0f4 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * PIMS IPC
  *
- * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the License);
  * you may not use this file except in compliance with the License.
index 0f85bb8..7946626 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * PIMS IPC
  *
- * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the License);
  * you may not use this file except in compliance with the License.
index 3244c34..54d4c2f 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * PIMS IPC
  *
- * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the License);
  * you may not use this file except in compliance with the License.
index f192ec9..fe7837c 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * PIMS IPC
  *
- * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the License);
  * you may not use this file except in compliance with the License.
index 8db0eb1..ee4e6f2 100644 (file)
@@ -1,6 +1,6 @@
 Name:       pims-ipc
 Summary:    library for PIMs IPC
-Version:    0.0.22
+Version:    0.0.28
 Release:    1
 Group:      System/Libraries
 License:    Apache-2.0
@@ -18,7 +18,7 @@ library for PIMs IPC
 %package devel
 Summary:    DB library for calendar
 Group:      Development/Libraries
-Requires:   %{name} = %{version}
+Requires:   %{name} = %{version}-%{release}
 
 %description devel
 library for PIMs IPC (developement files)
index d0a5026..f9162a6 100644 (file)
@@ -3,8 +3,8 @@
                <domain name="pims-ipc"/>
        </define>
        <assign>
-               <filesystem path="@LIB_INSTALL_DIR@/libpims-ipc.so.1.0.1" label="_" />
-               <filesystem path="@LIB_INSTALL_DIR@/libpims-ipc.so.1" label="_" />
+               <filesystem path="@LIB_INSTALL_DIR@/libpims-ipc.so.0.0.28" label="_" />
+               <filesystem path="@LIB_INSTALL_DIR@/libpims-ipc.so.0" label="_" />
        </assign>
        <request>
                <domain name="pims-ipc" />
index 055ed62..62b7076 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * PIMS IPC
  *
- * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the License);
  * you may not use this file except in compliance with the License.
@@ -44,7 +44,7 @@ extern "C"
 #define LOG_WARN    "WARN"
 #define LOG_ERROR   "ERROR"
 #define __ug_log(logtype, tag, frmt, args...) \
-        do {printf("[%s][%s][%08x] %s:%s(%d) > "frmt"\n", logtype, tag, (unsigned int)pthread_self(), __MODULE__, __FUNCTION__, __LINE__, ##args);} while (0)
+        do {printf("[%s][%s][%08x] %s:%s(%d) > "frmt"\n", logtype, tag, (unsigned int)pthread_self(), __FILE__, __FUNCTION__, __LINE__, ##args);} while (0)
 #endif
 
 #define pims_verbose(tag, frmt, args...) __ug_log(LOG_VERBOSE, tag, frmt, ##args)
index 98de999..03c5736 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * PIMS IPC
  *
- * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the License);
  * you may not use this file except in compliance with the License.
index 86d39be..fa0ee5d 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * PIMS IPC
  *
- * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the License);
  * you may not use this file except in compliance with the License.
index 86a05c1..ef48e0c 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * PIMS IPC
  *
- * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the License);
  * you may not use this file except in compliance with the License.
@@ -71,6 +71,15 @@ typedef struct
 static pims_ipc_svc_t *_g_singleton = NULL;
 static pims_ipc_svc_for_publish_t *_g_singleton_for_publish = NULL;
 
+#define PIMS_IPC_STRING_WORKER_ID_SIZE  10
+static char* __get_string_worker_id(int worker_id, char *string_worker_id)
+{
+    snprintf(string_worker_id, PIMS_IPC_STRING_WORKER_ID_SIZE, "%08x00", worker_id);
+    string_worker_id[PIMS_IPC_STRING_WORKER_ID_SIZE] = 0x0;
+
+    return string_worker_id;
+}
+
 API int pims_ipc_svc_init(char *service, gid_t group, mode_t mode)
 {
     if (_g_singleton)
@@ -458,7 +467,9 @@ static void* __worker_loop(void *args)
         ERROR("socket error : %s", zmq_strerror(errno));
         return NULL;
     }
-    if (zmq_setsockopt(worker, ZMQ_IDENTITY, &worker_id, sizeof(int)) != 0)
+    char string_worker_id[PIMS_IPC_STRING_WORKER_ID_SIZE + 1] = "";
+    if (zmq_setsockopt(worker, ZMQ_IDENTITY, __get_string_worker_id(worker_id, string_worker_id),
+                PIMS_IPC_STRING_WORKER_ID_SIZE) != 0)
     {
         ERROR("setsockopt error : %s", zmq_strerror(errno));
         zmq_close(worker);
@@ -482,7 +493,8 @@ static void* __worker_loop(void *args)
         zmq_close(worker);
         return NULL;
     }
-    if (zmq_setsockopt(manager, ZMQ_IDENTITY, &worker_id, sizeof(int)) != 0)
+    if (zmq_setsockopt(manager, ZMQ_IDENTITY, __get_string_worker_id(worker_id, string_worker_id),
+                PIMS_IPC_STRING_WORKER_ID_SIZE) != 0)
     {
         ERROR("setsockopt error : %s", zmq_strerror(errno));
         zmq_close(manager);
@@ -524,6 +536,9 @@ static void* __worker_loop(void *args)
 
         if (zmq_poll(items, 2, -1) == -1)
         {
+            if (errno == EINTR)
+                continue;
+
             ERROR("poll error : %s", zmq_strerror(errno));
             break;
         }
@@ -618,8 +633,10 @@ static void __terminate_worker(void *manager, int worker_id, const char *pid)
 {
     // send worker id
     zmq_msg_t worker_id_msg;
-    zmq_msg_init_size(&worker_id_msg, sizeof(int));
-    memcpy(zmq_msg_data(&worker_id_msg), &worker_id, sizeof(int));
+    zmq_msg_init_size(&worker_id_msg, PIMS_IPC_STRING_WORKER_ID_SIZE);
+    char string_worker_id[PIMS_IPC_STRING_WORKER_ID_SIZE + 1] = "";
+    memcpy(zmq_msg_data(&worker_id_msg), __get_string_worker_id(worker_id, string_worker_id),
+            PIMS_IPC_STRING_WORKER_ID_SIZE);
     if (_pims_zmq_msg_send(&worker_id_msg, manager, ZMQ_SNDMORE) == -1)
     {
         ERROR("send error : %s", zmq_strerror(errno));
@@ -819,8 +836,10 @@ static int __process_router_event(void *context, void *router, void *worker, gbo
         VERBOSE("routing worker id = %x", worker_id);
         // send worker id
         zmq_msg_t worker_id_msg;
-        zmq_msg_init_size(&worker_id_msg, sizeof(int));
-        memcpy(zmq_msg_data(&worker_id_msg), &worker_id, sizeof(int));
+        zmq_msg_init_size(&worker_id_msg, PIMS_IPC_STRING_WORKER_ID_SIZE);
+        char string_worker_id[PIMS_IPC_STRING_WORKER_ID_SIZE + 1] = "";
+        memcpy(zmq_msg_data(&worker_id_msg), __get_string_worker_id(worker_id, string_worker_id),
+                PIMS_IPC_STRING_WORKER_ID_SIZE);
         if (_pims_zmq_msg_send(&worker_id_msg, worker, ZMQ_SNDMORE) == -1)
         {
             ERROR("send error : %s", zmq_strerror(errno));
index 5f9be24..301a52f 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * PIMS IPC
  *
- * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the License);
  * you may not use this file except in compliance with the License.
@@ -83,6 +83,58 @@ typedef struct
     GHashTable *subscribe_cb_table;
 } pims_ipc_t;
 
+#define PIMS_IPC_SOCKET_BUFFER_SIZE     256
+static inline int __pims_zmq_msg_recv_by_handle(zmq_msg_t *msg, pims_ipc_t *handle, int flags)
+{
+    int ret = -1;
+
+    while (1)
+    {
+        zmq_pollitem_t items[] = {
+            {handle->requester, 0, ZMQ_POLLIN, 0},
+            {NULL, handle->fd, ZMQ_POLLIN, 0}
+        };
+
+        if (zmq_poll(items, 2, -1) == -1)
+        {
+            if (errno == EINTR)
+                continue;
+            
+            ERROR("poll error : %s", zmq_strerror(errno));
+            break;
+        }
+
+        if (items[0].revents & ZMQ_POLLIN)
+        {
+            ret = zmq_msg_recv(msg, handle->requester, flags);
+            if (ret == -1 && errno == EINTR)
+                continue;
+            break;
+        }
+
+        if (items[1].revents & ZMQ_POLLIN)
+        {
+            char buffer[PIMS_IPC_SOCKET_BUFFER_SIZE] = "";
+           
+            memset(buffer, 0x00, PIMS_IPC_SOCKET_BUFFER_SIZE);
+            ret = read(handle->fd, (char *)buffer, PIMS_IPC_SOCKET_BUFFER_SIZE-1);
+            ASSERT(ret <= 0);
+            
+            close(handle->fd);
+            handle->fd = -1;
+
+            if (handle->requester)
+                zmq_close(handle->requester);
+            handle->requester = NULL;
+
+            errno = ETERM;
+            ret = -1;
+            break;
+        }
+    }
+
+    return ret;
+}
 
 static void __pims_ipc_free_handle(pims_ipc_t *handle)
 {
@@ -143,7 +195,7 @@ static int __pims_ipc_receive_for_subscribe(pims_ipc_t *handle)
 
     do {
         // recv call id 
-        if (_pims_zmq_msg_recv(&call_id_msg, handle->requester, 0) == -1)
+        if (__pims_zmq_msg_recv_by_handle(&call_id_msg, handle, 0) == -1)
         {
             ERROR("recv error : %s", zmq_strerror(errno));
             break;
@@ -156,7 +208,7 @@ static int __pims_ipc_receive_for_subscribe(pims_ipc_t *handle)
         zmq_getsockopt(handle->requester, ZMQ_RCVMORE, &more, &more_size);
         if (more)
         {
-            if (_pims_zmq_msg_recv(&data_msg, handle->requester, 0) == -1)
+            if (__pims_zmq_msg_recv_by_handle(&data_msg, handle, 0) == -1)
             {
                 ERROR("recv error : %s", zmq_strerror(errno));
                 break;
@@ -531,7 +583,7 @@ static int __pims_ipc_receive(pims_ipc_t *handle, pims_ipc_data_h *data_out)
 
         do {
             // recv sequence no
-            if (_pims_zmq_msg_recv(&sequence_no_msg, handle->requester, 0) == -1)
+            if (__pims_zmq_msg_recv_by_handle(&sequence_no_msg, handle, 0) == -1)
             {
                 ERROR("recv error : %s", zmq_strerror(errno));
                 break;
@@ -539,7 +591,7 @@ static int __pims_ipc_receive(pims_ipc_t *handle, pims_ipc_data_h *data_out)
             memcpy(&sequence_no, zmq_msg_data(&sequence_no_msg), sizeof(unsigned int));
 
             // recv call id 
-            if (_pims_zmq_msg_recv(&call_id_msg, handle->requester, 0) == -1)
+            if (__pims_zmq_msg_recv_by_handle(&call_id_msg, handle, 0) == -1)
             {
                 ERROR("recv error : %s", zmq_strerror(errno));
                 break;
@@ -549,7 +601,7 @@ static int __pims_ipc_receive(pims_ipc_t *handle, pims_ipc_data_h *data_out)
             zmq_getsockopt(handle->requester, ZMQ_RCVMORE, &more, &more_size);
             if (more)
             {
-                if (_pims_zmq_msg_recv(&data_out_msg, handle->requester, 0) == -1)
+                if (__pims_zmq_msg_recv_by_handle(&data_out_msg, handle, 0) == -1)
                 {
                     ERROR("recv error : %s", zmq_strerror(errno));
                     break;
index f2ee131..bf02682 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * PIMS IPC
  *
- * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the License);
  * you may not use this file except in compliance with the License.
index 5cf2696..790e3d0 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * PIMS IPC
  *
- * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the License);
  * you may not use this file except in compliance with the License.
index b086864..a18e6f2 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * PIMS IPC
  *
- * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index 6335a38..74e0b8a 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * PIMS IPC
  *
- * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.