Signed-off-by: Angus Salkeld <asalkeld(a)redhat.com>
---
lib/ipc_int.h | 15 ++++++++-------
lib/ipc_posix_mq.c | 34 +++++++++++++++++-----------------
lib/ipc_shm.c | 40 ++++++++++++++++++++--------------------
lib/ipc_sysv_mq.c | 31 +++++++++++++++----------------
4 files changed, 60 insertions(+), 60 deletions(-)
diff --git a/lib/ipc_int.h b/lib/ipc_int.h
index 7e30631..a2efbdf 100644
--- a/lib/ipc_int.h
+++ b/lib/ipc_int.h
@@ -78,19 +78,19 @@ struct qb_ipcc_shm_one_way {
struct qb_ipcc_pmq_connection {
struct qb_ipcc_pmq_one_way request;
struct qb_ipcc_pmq_one_way response;
- struct qb_ipcc_pmq_one_way dispatch;
+ struct qb_ipcc_pmq_one_way event;
};
struct qb_ipcc_smq_connection {
struct qb_ipcc_smq_one_way request;
struct qb_ipcc_smq_one_way response;
- struct qb_ipcc_smq_one_way dispatch;
+ struct qb_ipcc_smq_one_way event;
};
struct qb_ipcc_shm_connection {
struct qb_ipcc_shm_one_way request;
struct qb_ipcc_shm_one_way response;
- struct qb_ipcc_shm_one_way dispatch;
+ struct qb_ipcc_shm_one_way event;
};
struct qb_ipcc_connection {
@@ -179,6 +179,7 @@ int32_t qb_ipcs_shm_create(struct qb_ipcs_service *s);
int32_t qb_ipcs_us_publish(struct qb_ipcs_service *s);
int32_t qb_ipcs_us_withdraw(struct qb_ipcs_service *s);
+
int32_t qb_ipcs_dispatch_connection_request(qb_handle_t hdb_handle_t,
int32_t fd, int32_t revents, void *data);
int32_t qb_ipcs_dispatch_service_request(qb_handle_t hdb_handle_t,
@@ -187,6 +188,7 @@ struct qb_ipcs_connection* qb_ipcs_connection_alloc(struct
qb_ipcs_service *s);
int32_t qb_ipcs_process_request(struct qb_ipcs_service *s,
struct qb_ipc_request_header *hdr);
+
void qb_ipcs_disconnect(struct qb_ipcs_connection *c);
struct mar_req_initial_setup {
@@ -200,27 +202,26 @@ struct mar_res_initial_setup {
uint32_t max_msg_size __attribute__ ((aligned(8)));
} __attribute__ ((aligned(8)));
-
struct mar_req_shm_setup {
struct qb_ipc_request_header hdr __attribute__ ((aligned(8)));
uint32_t pid __attribute__ ((aligned(8)));
char request[PATH_MAX] __attribute__ ((aligned(8)));
char response[PATH_MAX] __attribute__ ((aligned(8)));
- char dispatch[PATH_MAX] __attribute__ ((aligned(8)));
+ char event[PATH_MAX] __attribute__ ((aligned(8)));
} __attribute__ ((aligned(8)));
struct mar_req_pmq_setup {
struct qb_ipc_request_header hdr __attribute__ ((aligned(8)));
uint32_t pid __attribute__ ((aligned(8)));
char response_mq[NAME_MAX] __attribute__ ((aligned(8)));
- char dispatch_mq[NAME_MAX] __attribute__ ((aligned(8)));
+ char event_mq[NAME_MAX] __attribute__ ((aligned(8)));
} __attribute__ ((aligned(8)));
struct mar_req_smq_setup {
struct qb_ipc_request_header hdr __attribute__ ((aligned(8)));
uint32_t pid __attribute__ ((aligned(8)));
int32_t response_key __attribute__ ((aligned(8)));
- int32_t dispatch_key __attribute__ ((aligned(8)));
+ int32_t event_key __attribute__ ((aligned(8)));
} __attribute__ ((aligned(8)));
struct mar_res_setup {
diff --git a/lib/ipc_posix_mq.c b/lib/ipc_posix_mq.c
index 293f8c4..ff8c0ed 100644
--- a/lib/ipc_posix_mq.c
+++ b/lib/ipc_posix_mq.c
@@ -26,7 +26,7 @@
#include "util_int.h"
#include <qb/qbpoll.h>
-static ssize_t qb_ipcs_pmq_dispatch_send(struct qb_ipcs_connection *c,
+static ssize_t qb_ipcs_pmq_event_send(struct qb_ipcs_connection *c,
void *data, size_t size);
/*
@@ -165,8 +165,8 @@ static void qb_ipcc_pmq_disconnect(struct qb_ipcc_connection *c)
hdr.size = sizeof(hdr);
mq_send(c->u.pmq.request.q, (const char *)&hdr, hdr.size, 30);
- mq_close(c->u.pmq.dispatch.q);
- mq_unlink(c->u.pmq.dispatch.name);
+ mq_close(c->u.pmq.event.q);
+ mq_unlink(c->u.pmq.event.name);
mq_close(c->u.pmq.response.q);
mq_unlink(c->u.pmq.response.name);
@@ -187,7 +187,7 @@ static int32_t _ipcc_pmq_connect_to_service_(struct qb_ipcc_connection
*c)
start.pid = getpid();
start.hdr.size = sizeof(struct mar_req_pmq_setup);
strcpy(start.response_mq, c->u.pmq.response.name);
- strcpy(start.dispatch_mq, c->u.pmq.dispatch.name);
+ strcpy(start.event_mq, c->u.pmq.event.name);
res =
mq_send(c->u.pmq.request.q, (const char *)&start, start.hdr.size,
@@ -272,18 +272,18 @@ int32_t qb_ipcc_pmq_connect(struct qb_ipcc_connection * c)
}
res =
- snprintf(c->u.pmq.dispatch.name, NAME_MAX, "/%s-dispatch-%d",
+ snprintf(c->u.pmq.event.name, NAME_MAX, "/%s-event-%d",
c->name, getpid());
posix_mq_increase_limits(c->max_msg_size, 10);
- c->u.pmq.dispatch.q = posix_mq_create(c->u.pmq.dispatch.name,
+ c->u.pmq.event.q = posix_mq_create(c->u.pmq.event.name,
c->max_msg_size,
O_RDONLY | O_CREAT | O_EXCL |
O_NONBLOCK);
- if (c->u.pmq.dispatch.q == (mqd_t)-1) {
+ if (c->u.pmq.event.q == (mqd_t)-1) {
res = -errno;
- perror("mq_open:DISPATCH");
+ perror("mq_open:event");
goto cleanup_request_response;
}
@@ -292,8 +292,8 @@ int32_t qb_ipcc_pmq_connect(struct qb_ipcc_connection * c)
return 0;
}
- mq_close(c->u.pmq.dispatch.q);
- mq_unlink(c->u.pmq.dispatch.name);
+ mq_close(c->u.pmq.event.q);
+ mq_unlink(c->u.pmq.event.name);
cleanup_request_response:
mq_close(c->u.pmq.response.q);
@@ -319,7 +319,7 @@ static void qb_ipcs_pmq_disconnect(struct qb_ipcs_connection *c)
msg.size = sizeof(msg);
msg.error = 0;
- qb_ipcs_pmq_dispatch_send(c, &msg, msg.size);
+ qb_ipcs_pmq_event_send(c, &msg, msg.size);
}
static void qb_ipcs_pmq_destroy(struct qb_ipcs_service *s)
@@ -373,14 +373,14 @@ static int32_t qb_ipcs_pmq_connect(struct qb_ipcs_service *s,
return res;
}
- /* setup the dispatch message queue
+ /* setup the event message queue
*/
posix_mq_increase_limits(c->service->max_msg_size, 10);
- strcpy(c->u.pmq.dispatch.name, init->dispatch_mq);
- c->u.pmq.dispatch.q = mq_open(c->u.pmq.dispatch.name,
+ strcpy(c->u.pmq.event.name, init->event_mq);
+ c->u.pmq.event.q = mq_open(c->u.pmq.event.name,
O_WRONLY | O_NONBLOCK);
- if (c->u.pmq.dispatch.q == (mqd_t)-1) {
+ if (c->u.pmq.event.q == (mqd_t)-1) {
res = -errno;
goto cleanup_response;
}
@@ -439,10 +439,10 @@ static ssize_t qb_ipcs_pmq_response_send(struct qb_ipcs_connection
*c,
return size;
}
-static ssize_t qb_ipcs_pmq_dispatch_send(struct qb_ipcs_connection *c,
+static ssize_t qb_ipcs_pmq_event_send(struct qb_ipcs_connection *c,
void *data, size_t size)
{
- if (mq_send(c->u.pmq.dispatch.q, (const char *)data, size, 1) == -1) {
+ if (mq_send(c->u.pmq.event.q, (const char *)data, size, 1) == -1) {
return -errno;
}
return size;
diff --git a/lib/ipc_shm.c b/lib/ipc_shm.c
index 9747b58..bdf9149 100644
--- a/lib/ipc_shm.c
+++ b/lib/ipc_shm.c
@@ -25,7 +25,7 @@
#include <qb/qbpoll.h>
#include <qb/qbrb.h>
-static ssize_t qb_ipcs_shm_dispatch_send(struct qb_ipcs_connection *c,
+static ssize_t qb_ipcs_shm_event_send(struct qb_ipcs_connection *c,
void *data, size_t size);
/*
@@ -40,7 +40,7 @@ static void qb_ipcc_shm_disconnect(struct qb_ipcc_connection *c)
{
qb_rb_close(c->u.shm.request.rb);
qb_rb_close(c->u.shm.response.rb);
- qb_rb_close(c->u.shm.dispatch.rb);
+ qb_rb_close(c->u.shm.event.rb);
}
static int32_t qb_ipcc_shm_send(struct qb_ipcc_connection *c,
@@ -72,7 +72,7 @@ static int32_t _ipcc_shm_connect_to_service_(struct qb_ipcc_connection
*c)
start.pid = getpid();
start.hdr.size = sizeof(struct mar_req_shm_setup);
strcpy(start.response, qb_rb_name_get(c->u.shm.response.rb));
- strcpy(start.dispatch, qb_rb_name_get(c->u.shm.dispatch.rb));
+ strcpy(start.event, qb_rb_name_get(c->u.shm.event.rb));
c->needs_sock_for_poll = QB_TRUE;
@@ -96,7 +96,7 @@ static int32_t _ipcc_shm_connect_to_service_(struct qb_ipcc_connection
*c)
perror("_ipcc_shm_connect_to_service_:qb_rb_chunk_read");
goto cleanup;
}
- qb_util_log(LOG_DEBUG, "received response from server %zd\n", size);
+ qb_util_log(LOG_DEBUG, "received response from server size:%zd\n", size);
msg_res = (struct mar_res_setup *)c->receive_buf;
res = msg_res->hdr.error;
if (res == 0) {
@@ -145,17 +145,17 @@ int32_t qb_ipcc_shm_connect(struct qb_ipcc_connection * c)
}
res =
- snprintf(c->u.shm.dispatch.name, NAME_MAX, "%s-dispatch-%d",
+ snprintf(c->u.shm.event.name, NAME_MAX, "%s-event-%d",
c->name, getpid());
- c->u.shm.dispatch.rb = qb_rb_open(c->u.shm.dispatch.name,
+ c->u.shm.event.rb = qb_rb_open(c->u.shm.event.name,
c->max_msg_size,
QB_RB_FLAG_CREATE |
QB_RB_FLAG_SHARED_PROCESS);
- if (c->u.shm.dispatch.rb == NULL) {
+ if (c->u.shm.event.rb == NULL) {
res = -errno;
- perror("qb_rb_open:DISPATCH");
+ perror("qb_rb_open:EVENT");
goto cleanup_request_response;
}
@@ -166,7 +166,7 @@ int32_t qb_ipcc_shm_connect(struct qb_ipcc_connection * c)
qb_util_log(LOG_DEBUG, "connection failed %d\n", res);
- qb_rb_close(c->u.shm.dispatch.rb);
+ qb_rb_close(c->u.shm.event.rb);
cleanup_request_response:
qb_rb_close(c->u.shm.response.rb);
@@ -191,11 +191,11 @@ static void qb_ipcs_shm_disconnect(struct qb_ipcs_connection *c)
msg.error = 0;
if (c->u.shm.response.rb) {
- qb_ipcs_shm_dispatch_send(c, &msg, msg.size);
+ qb_ipcs_shm_event_send(c, &msg, msg.size);
qb_rb_close(c->u.shm.response.rb);
}
- if (c->u.shm.dispatch.rb) {
- qb_rb_close(c->u.shm.dispatch.rb);
+ if (c->u.shm.event.rb) {
+ qb_rb_close(c->u.shm.event.rb);
}
}
@@ -247,17 +247,17 @@ static int32_t qb_ipcs_shm_connect(struct qb_ipcs_service *s,
return res;
}
- /* setup the dispatch message queue
+ /* setup the event message queue
*/
- strcpy(c->u.shm.dispatch.name, init->dispatch);
- qb_util_log(LOG_DEBUG, "%s:%s", __func__, c->u.shm.dispatch.name);
- c->u.shm.dispatch.rb = qb_rb_open(c->u.shm.dispatch.name,
+ strcpy(c->u.shm.event.name, init->event);
+ qb_util_log(LOG_DEBUG, "%s:%s", __func__, c->u.shm.event.name);
+ c->u.shm.event.rb = qb_rb_open(c->u.shm.event.name,
s->max_msg_size,
QB_RB_FLAG_SHARED_PROCESS);
- if (c->u.shm.dispatch.rb == NULL) {
+ if (c->u.shm.event.rb == NULL) {
res = -errno;
- perror("mq_open:DISPATCH");
+ perror("mq_open:EVENT");
goto cleanup_response;
}
@@ -305,10 +305,10 @@ static ssize_t qb_ipcs_shm_response_send(struct qb_ipcs_connection
*c,
size);
}
-static ssize_t qb_ipcs_shm_dispatch_send(struct qb_ipcs_connection *c,
+static ssize_t qb_ipcs_shm_event_send(struct qb_ipcs_connection *c,
void *data, size_t size)
{
- return qb_rb_chunk_write(c->u.shm.dispatch.rb, (const char *)data,
+ return qb_rb_chunk_write(c->u.shm.event.rb, (const char *)data,
size);
}
diff --git a/lib/ipc_sysv_mq.c b/lib/ipc_sysv_mq.c
index 51fb4cd..fb93be9 100644
--- a/lib/ipc_sysv_mq.c
+++ b/lib/ipc_sysv_mq.c
@@ -30,7 +30,7 @@
#define MSGMAX 8192
#endif
-static ssize_t qb_ipcs_smq_dispatch_send(struct qb_ipcs_connection *c,
+static ssize_t qb_ipcs_smq_event_send(struct qb_ipcs_connection *c,
void *data, size_t size);
/*
@@ -137,7 +137,7 @@ static void qb_ipcc_smq_disconnect(struct qb_ipcc_connection *c)
hdr.size = sizeof(hdr);
msgsnd(c->u.smq.request.q, (const char *)&hdr, hdr.size, 0);
- msgctl(c->u.smq.dispatch.q, IPC_RMID, NULL);
+ msgctl(c->u.smq.event.q, IPC_RMID, NULL);
msgctl(c->u.smq.response.q, IPC_RMID, NULL);
}
@@ -154,7 +154,7 @@ static int32_t _smq_connect_to_service_(struct qb_ipcc_connection *c)
start.pid = getpid();
start.hdr.size = sizeof(struct mar_req_smq_setup);
start.response_key = c->u.smq.response.key;
- start.dispatch_key = c->u.smq.dispatch.key;
+ start.event_key = c->u.smq.event.key;
if (c->needs_sock_for_poll) {
qb_ipc_us_send(c->sock, &start, 1);
@@ -236,11 +236,11 @@ int32_t qb_ipcc_smq_connect(struct qb_ipcc_connection * c)
goto cleanup_request;
}
- /* Create the dispatch message queue.
+ /* Create the event message queue.
*/
- res = sysv_mq_unnamed_create(&c->u.smq.dispatch);
+ res = sysv_mq_unnamed_create(&c->u.smq.event);
if (res < 0) {
- perror("msgget:DISPATCH");
+ perror("msgget:event");
goto cleanup_request_response;
}
@@ -249,13 +249,12 @@ int32_t qb_ipcc_smq_connect(struct qb_ipcc_connection * c)
return 0;
}
- msgctl(c->u.smq.dispatch.q, IPC_RMID, NULL);
+ msgctl(c->u.smq.event.q, IPC_RMID, NULL);
cleanup_request_response:
msgctl(c->u.smq.response.q, IPC_RMID, NULL);
cleanup_request:
- free(c);
return res;
}
@@ -276,7 +275,7 @@ static void qb_ipcs_smq_disconnect(struct qb_ipcs_connection *c)
msg.size = sizeof(msg);
msg.error = 0;
- qb_ipcs_smq_dispatch_send(c, &msg, msg.size);
+ qb_ipcs_smq_event_send(c, &msg, msg.size);
}
static void qb_ipcs_smq_destroy(struct qb_ipcs_service *s)
@@ -327,13 +326,13 @@ static int32_t qb_ipcs_smq_connect(struct qb_ipcs_service *s,
goto cleanup;
}
- /* setup the dispatch message queue
+ /* setup the event message queue
*/
- c->u.smq.dispatch.key = init->dispatch_key;
- c->u.smq.dispatch.q = msgget(c->u.smq.dispatch.key, IPC_NOWAIT);
- if (c->u.smq.dispatch.q == -1) {
+ c->u.smq.event.key = init->event_key;
+ c->u.smq.event.q = msgget(c->u.smq.event.key, IPC_NOWAIT);
+ if (c->u.smq.event.q == -1) {
res = -errno;
- perror("msgget:DISPATCH");
+ perror("msgget:event");
goto cleanup_response;
}
@@ -400,10 +399,10 @@ static ssize_t qb_ipcs_smq_response_send(struct qb_ipcs_connection
*c,
return size;
}
-static ssize_t qb_ipcs_smq_dispatch_send(struct qb_ipcs_connection *c,
+static ssize_t qb_ipcs_smq_event_send(struct qb_ipcs_connection *c,
void *data, size_t size)
{
- ssize_t res = msgsnd(c->u.smq.dispatch.q, (const char *)data, size, 0);
+ ssize_t res = msgsnd(c->u.smq.event.q, (const char *)data, size, 0);
if (res == -1) {
return -errno;
}
--
1.7.2.3