mirror of
https://salsa.debian.org/ha-team/libqb
synced 2025-12-30 18:22:35 +00:00
IPC: make events always use socket notification
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
This commit is contained in:
parent
e7aad8fad5
commit
82c13bdd2b
@ -24,6 +24,7 @@
|
||||
|
||||
#include <unistd.h>
|
||||
#include "config.h"
|
||||
|
||||
#include <dirent.h>
|
||||
#include <mqueue.h>
|
||||
#include <qb/qblist.h>
|
||||
@ -71,8 +72,6 @@ struct qb_ipc_connection_response {
|
||||
char event[PATH_MAX] __attribute__ ((aligned(8)));
|
||||
} __attribute__ ((aligned(8)));
|
||||
|
||||
|
||||
|
||||
struct qb_ipcc_connection;
|
||||
|
||||
struct qb_ipc_one_way {
|
||||
|
||||
@ -80,7 +80,7 @@ static int32_t posix_mq_open(struct qb_ipc_one_way *one_way,
|
||||
if (res != 0) {
|
||||
return res;
|
||||
}
|
||||
one_way->u.pmq.q = mq_open(name, O_RDWR | O_NONBLOCK);
|
||||
one_way->u.pmq.q = mq_open(name, O_RDWR);
|
||||
if (one_way->u.pmq.q == (mqd_t) - 1) {
|
||||
res = -errno;
|
||||
perror("mq_open");
|
||||
@ -400,14 +400,6 @@ cleanup:
|
||||
return res;
|
||||
}
|
||||
|
||||
#warning TODO implement this.
|
||||
#if 0
|
||||
static int32_t qb_ipcc_pmq_fd_get(struct qb_ipcc_connection *c)
|
||||
{
|
||||
return c->response.u.pmq.q;
|
||||
}
|
||||
#endif
|
||||
|
||||
int32_t qb_ipcs_pmq_create(struct qb_ipcs_service * s)
|
||||
{
|
||||
s->funcs.recv = qb_ipc_pmq_recv;
|
||||
|
||||
18
lib/ipcc.c
18
lib/ipcc.c
@ -153,11 +153,7 @@ ssize_t qb_ipcc_recv(struct qb_ipcc_connection * c, void *msg_ptr,
|
||||
|
||||
int32_t qb_ipcc_fd_get(struct qb_ipcc_connection * c, int32_t * fd)
|
||||
{
|
||||
if (c->needs_sock_for_poll) {
|
||||
*fd = c->sock;
|
||||
} else {
|
||||
*fd = 0; /*TODO?? */
|
||||
}
|
||||
*fd = c->sock;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -165,15 +161,13 @@ ssize_t qb_ipcc_event_recv(struct qb_ipcc_connection * c, void *msg_pt,
|
||||
size_t msg_len, int32_t ms_timeout)
|
||||
{
|
||||
char one_byte = 1;
|
||||
int32_t res = 0;
|
||||
int32_t res;
|
||||
|
||||
if (c->needs_sock_for_poll) {
|
||||
res = qb_ipc_us_recv_ready(c->sock, ms_timeout);
|
||||
if (res < 0) {
|
||||
return res;
|
||||
}
|
||||
qb_ipc_us_recv(c->sock, &one_byte, 1);
|
||||
res = qb_ipc_us_recv_ready(c->sock, ms_timeout);
|
||||
if (res < 0) {
|
||||
return res;
|
||||
}
|
||||
qb_ipc_us_recv(c->sock, &one_byte, 1);
|
||||
return c->funcs.recv(&c->event, msg_pt, msg_len, ms_timeout);
|
||||
}
|
||||
|
||||
|
||||
12
lib/ipcs.c
12
lib/ipcs.c
@ -144,11 +144,9 @@ ssize_t qb_ipcs_event_send(struct qb_ipcs_connection *c, const void *data,
|
||||
ssize_t res;
|
||||
|
||||
qb_ipcs_connection_ref_inc(c);
|
||||
res = c->service->funcs.send(&c->event, data, size);
|
||||
|
||||
if (c->service->needs_sock_for_poll) {
|
||||
qb_ipc_us_send(c->sock, data, 1);
|
||||
}
|
||||
res = c->service->funcs.send(&c->event, data, size);
|
||||
qb_ipc_us_send(c->sock, data, 1);
|
||||
|
||||
qb_ipcs_connection_ref_dec(c);
|
||||
|
||||
@ -161,11 +159,9 @@ ssize_t qb_ipcs_event_sendv(qb_ipcs_connection_t *c, const struct iovec * iov, s
|
||||
ssize_t res;
|
||||
|
||||
qb_ipcs_connection_ref_inc(c);
|
||||
res = c->service->funcs.sendv(&c->event, iov, iov_len);
|
||||
|
||||
if (c->service->needs_sock_for_poll) {
|
||||
qb_ipc_us_send(c->sock, &res, 1);
|
||||
}
|
||||
res = c->service->funcs.sendv(&c->event, iov, iov_len);
|
||||
qb_ipc_us_send(c->sock, &res, 1);
|
||||
|
||||
qb_ipcs_connection_ref_dec(c);
|
||||
|
||||
|
||||
@ -273,12 +273,6 @@ ssize_t qb_rb_space_free(qb_ringbuffer_t * rb)
|
||||
return space_free;
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO write a function that returns the number of chunks
|
||||
* in the rb.
|
||||
*
|
||||
*/
|
||||
|
||||
static size_t _qb_rb_space_used_locked_(qb_ringbuffer_t * rb)
|
||||
{
|
||||
uint32_t write_size;
|
||||
|
||||
@ -377,7 +377,6 @@ int32_t qb_rb_lock_create(struct qb_ringbuffer_s * rb, uint32_t flags)
|
||||
#if _POSIX_THREAD_PROCESS_SHARED > 0
|
||||
can_use_shared_posix = 1;
|
||||
#endif
|
||||
|
||||
if (((rb->flags & QB_RB_FLAG_SHARED_PROCESS) == 0) &&
|
||||
(rb->flags & QB_RB_FLAG_SHARED_THREAD) == 0) {
|
||||
rb->lock_fn = my_null_fn;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user