ClusterLabs / ClusterLabs/libqb
[new API] two-phased qb_ipcs_create required
- Dominant language
- C
- Stars
- 171
- Forks
- 103
- PR merge metrics
- No merged PRs in 30d
Description
Signatures
```
/* Creates a listening UNIX socket, akin to qb_ipcs_create */
qb_ipcs_listener_t* qb_ipcs_listener(const char *name);
/* Gets socket descriptor from listener; to prevent further
use (the same information is now at two places at minimum),
deallocates l, so _it must not be reused elsewhere from that
point on_ */
int qb_ipcs_listener_fd(const qb_ipcs_listener_t *l);
/* Wraps a listening UNIX socket, presumably created with
qb_ipcs_listener and subsequently extracted with qb_ipcs_listener_fd
(e.g. the name gets validated), extracting "name" using
getsockname(2); _fd must not be reused elsewhere from that point on_ */
qb_ipcs_listener_t* qb_ipcs_listener_from_fd(int fd);
/* Reuses existing UNIX socket wrapped in a listener object;
qb_ipcs_listener + qb_ipcs_create_from_listener equals qb_ipcs_create;
to prevent further use, deallocates l, so _it must not be reused
elsewhere from that point on_ */
qb_ipcs_service_t* qb_ipcs_create_from_listener(qb_ipcs_listener_t *l,
int32_t service_id,
enum qb_ipc_type type,
struct qb_ipcs_service_handlers *handlers);
```
Allow safe nesting wrt. NULL checking, e.g.,
```
qb_ipcs_create_from_listener(qb_ipcs_listener_from_fd(qb_ipcs_listener_fd(qb_ipcs_listener("foo"))),
42, QB_IPC_SHM, handlers);
```
The `qb_ipcs_listener_t` abstraction is meant to allow for (and enforce)
extra checking on libqb side (so that the same internal coherency as with
monolithic `qb_ipcs_create` is achieved), as that type is only used as
an opaque pointer in the client program.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.