Signed-off-by: Angus Salkeld <asalkeld(a)redhat.com>
---
lib/ipc_posix_mq.c | 10 ++++++++++
lib/ipc_shm.c | 12 ++++++++----
lib/ipc_sysv_mq.c | 2 ++
lib/ipcc.c | 6 +-----
lib/ipcs.c | 6 ++----
5 files changed, 23 insertions(+), 13 deletions(-)
diff --git a/lib/ipc_posix_mq.c b/lib/ipc_posix_mq.c
index ed1d11e..ef3fa60 100644
--- a/lib/ipc_posix_mq.c
+++ b/lib/ipc_posix_mq.c
@@ -214,6 +214,11 @@ int32_t qb_ipcc_pmq_connect(struct qb_ipcc_connection * c)
c->funcs.send = qb_ipcc_pmq_send;
c->funcs.recv = qb_ipcc_pmq_recv;
c->funcs.disconnect = qb_ipcc_pmq_disconnect;
+#if defined(QB_LINUX) || defined(QB_BSD)
+ c->needs_sock_for_poll = QB_FALSE;
+#else
+ c->needs_sock_for_poll = QB_TRUE;
+#endif
if (strlen(c->name) > (NAME_MAX - 20)) {
return -EINVAL;
@@ -441,6 +446,11 @@ int32_t qb_ipcs_pmq_create(struct qb_ipcs_service * s)
s->funcs.response_send = qb_ipcs_pmq_response_send;
s->funcs.connect = qb_ipcs_pmq_connect;
s->funcs.disconnect = qb_ipcs_pmq_disconnect;
+#if defined(QB_LINUX) || defined(QB_BSD)
+ s->needs_sock_for_poll = QB_FALSE;
+#else
+ s->needs_sock_for_poll = QB_TRUE;
+#endif
posix_mq_increase_limits(s->max_msg_size, 10);
s->u.q = posix_mq_create(mq_name, s->max_msg_size,
diff --git a/lib/ipc_shm.c b/lib/ipc_shm.c
index bb7ffb0..b679a81 100644
--- a/lib/ipc_shm.c
+++ b/lib/ipc_shm.c
@@ -74,12 +74,15 @@ static int32_t _ipcc_shm_connect_to_service_(struct qb_ipcc_connection
*c)
strcpy(start.response, qb_rb_name_get(c->u.shm.response.rb));
strcpy(start.dispatch, qb_rb_name_get(c->u.shm.dispatch.rb));
- res =
- qb_rb_chunk_write(c->u.shm.request.rb, (const char *)&start,
- start.hdr.size);
+ c->needs_sock_for_poll = QB_TRUE;
+
+ res = qb_rb_chunk_write(c->u.shm.request.rb,
+ (const char *)&start,
+ start.hdr.size);
if (res < 0) {
return res;
}
+
if (c->needs_sock_for_poll) {
qb_ipc_us_send(c->sock, &start, 1);
}
@@ -318,6 +321,7 @@ int32_t qb_ipcs_shm_create(struct qb_ipcs_service *s)
s->funcs.response_send = qb_ipcs_shm_response_send;
s->funcs.connect = qb_ipcs_shm_connect;
s->funcs.disconnect = qb_ipcs_shm_disconnect;
+ s->needs_sock_for_poll = QB_TRUE;
s->u.rb = qb_rb_open(s->name, s->max_msg_size,
QB_RB_FLAG_CREATE | QB_RB_FLAG_SHARED_PROCESS);
@@ -327,6 +331,6 @@ int32_t qb_ipcs_shm_create(struct qb_ipcs_service *s)
return res;
}
- qb_util_log(LOG_DEBUG, "%s() %d", __func__, s->u.q);
+ qb_util_log(LOG_DEBUG, "%s()", __func__);
return res;
}
diff --git a/lib/ipc_sysv_mq.c b/lib/ipc_sysv_mq.c
index 9b241f8..30a8c27 100644
--- a/lib/ipc_sysv_mq.c
+++ b/lib/ipc_sysv_mq.c
@@ -197,6 +197,7 @@ int32_t qb_ipcc_smq_connect(struct qb_ipcc_connection * c)
c->funcs.recv = qb_ipcc_smq_recv;
c->funcs.disconnect = qb_ipcc_smq_disconnect;
c->type = QB_IPC_SYSV_MQ;
+ c->needs_sock_for_poll = QB_TRUE;
if (strlen(c->name) > (NAME_MAX - 20)) {
free(c);
@@ -419,6 +420,7 @@ int32_t qb_ipcs_smq_create(struct qb_ipcs_service * s)
s->funcs.disconnect = qb_ipcs_smq_disconnect;
s->funcs.response_send = qb_ipcs_smq_response_send;
s->funcs.request_recv = qb_ipcs_smq_request_recv;
+ s->needs_sock_for_poll = QB_TRUE;
s->max_msg_size = MSGMAX;
diff --git a/lib/ipcc.c b/lib/ipcc.c
index b21f503..53e75d8 100644
--- a/lib/ipcc.c
+++ b/lib/ipcc.c
@@ -71,28 +71,24 @@ qb_ipcc_connection_t *qb_ipcc_connect(const char *name, enum
qb_ipc_type type)
c->type = init_res.connection_type;
c->sock = usock;
c->session_id = init_res.session_id;
- printf("%s() max_msg_size:%d\n", __func__, init_res.max_msg_size);
c->max_msg_size = init_res.max_msg_size;
c->receive_buf = malloc(c->max_msg_size);
switch (c->type) {
case QB_IPC_SHM:
- c->needs_sock_for_poll = QB_TRUE;
res = qb_ipcc_shm_connect(c);
break;
case QB_IPC_POSIX_MQ:
- c->needs_sock_for_poll = QB_FALSE;
res = qb_ipcc_pmq_connect(c);
break;
case QB_IPC_SYSV_MQ:
- c->needs_sock_for_poll = QB_TRUE;
res = qb_ipcc_smq_connect(c);
break;
case QB_IPC_SOCKET:
c->needs_sock_for_poll = QB_FALSE;
break;
default:
- res = EINVAL;
+ res = -EINVAL;
break;
}
if (res != 0) {
diff --git a/lib/ipcs.c b/lib/ipcs.c
index 3e94007..16d6847 100644
--- a/lib/ipcs.c
+++ b/lib/ipcs.c
@@ -44,6 +44,7 @@ qb_ipcs_service_pt qb_ipcs_create(const char *name, enum qb_ipc_type
type,
s->type = type;
s->max_msg_size = max_msg_size;
s->receive_buf = malloc(s->max_msg_size);
+ s->needs_sock_for_poll = QB_FALSE;
qb_list_init(&s->connections);
snprintf(s->name, 255, "%s", name);
@@ -51,11 +52,8 @@ qb_ipcs_service_pt qb_ipcs_create(const char *name, enum qb_ipc_type
type,
switch (s->type) {
case QB_IPC_SOCKET:
case QB_IPC_POSIX_MQ:
- s->needs_sock_for_poll = QB_FALSE;
- break;
case QB_IPC_SYSV_MQ:
case QB_IPC_SHM:
- s->needs_sock_for_poll = QB_TRUE;
break;
default:
qb_hdb_handle_destroy(&qb_ipc_services, h);
@@ -126,7 +124,7 @@ int32_t qb_ipcs_run(qb_ipcs_service_pt pt, qb_handle_t poll_handle)
res = qb_ipcs_smq_create((struct qb_ipcs_service *)s);
break;
default:
- res = -ENOPROTOOPT;
+ res = -EINVAL;
break;
}
qb_hdb_handle_put(&qb_ipc_services, pt);
--
1.7.2.2