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")
-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
-Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
/*
* 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.
/*
* 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.
/*
* 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.
/*
* 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.
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
%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)
<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" />
/*
* 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.
#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)
/*
* 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.
/*
* 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.
/*
* 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.
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)
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);
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);
if (zmq_poll(items, 2, -1) == -1)
{
+ if (errno == EINTR)
+ continue;
+
ERROR("poll error : %s", zmq_strerror(errno));
break;
}
{
// 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));
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));
/*
* 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.
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)
{
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;
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;
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;
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;
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;
/*
* 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.
/*
* 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.
/*
* 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.
/*
* 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.