mirror of
https://salsa.debian.org/ha-team/libqb
synced 2026-02-03 03:46:13 +00:00
Merge pull request #68 from r1mikey/upstream
Add an IPC server service context
This commit is contained in:
commit
07c9b96872
@ -194,6 +194,25 @@ void qb_ipcs_unref(qb_ipcs_service_t *s);
|
||||
void qb_ipcs_poll_handlers_set(qb_ipcs_service_t* s,
|
||||
struct qb_ipcs_poll_handlers *handlers);
|
||||
|
||||
/**
|
||||
* Associate a "user" pointer with this service.
|
||||
*
|
||||
* @param s service instance
|
||||
* @param context the pointer to associate with this service.
|
||||
* @see qb_ipcs_service_context_get()
|
||||
*/
|
||||
void qb_ipcs_service_context_set(qb_ipcs_service_t* s,
|
||||
void *context);
|
||||
|
||||
/**
|
||||
* Get the context (set previously)
|
||||
*
|
||||
* @param s service instance
|
||||
* @return the context
|
||||
* @see qb_ipcs_service_context_set()
|
||||
*/
|
||||
void *qb_ipcs_service_context_get(qb_ipcs_service_t* s);
|
||||
|
||||
/**
|
||||
* run the new IPC server.
|
||||
* @param s service instance
|
||||
@ -321,6 +340,15 @@ void qb_ipcs_context_set(qb_ipcs_connection_t *c, void *context);
|
||||
*/
|
||||
void *qb_ipcs_context_get(qb_ipcs_connection_t *c);
|
||||
|
||||
/**
|
||||
* Get the context previously set on the service backing this connection
|
||||
*
|
||||
* @param c connection instance
|
||||
* @return the context
|
||||
* @see qb_ipcs_service_context_set
|
||||
*/
|
||||
void *qb_ipcs_connection_service_context_get(qb_ipcs_connection_t *c);
|
||||
|
||||
/**
|
||||
* Get the connection statistics.
|
||||
*
|
||||
|
||||
@ -147,6 +147,8 @@ struct qb_ipcs_service {
|
||||
struct qb_list_head connections;
|
||||
struct qb_list_head list;
|
||||
struct qb_ipcs_stats stats;
|
||||
|
||||
void *context;
|
||||
};
|
||||
|
||||
enum qb_ipcs_connection_state {
|
||||
|
||||
22
lib/ipcs.c
22
lib/ipcs.c
@ -85,6 +85,19 @@ qb_ipcs_poll_handlers_set(struct qb_ipcs_service *s,
|
||||
s->poll_fns.dispatch_del = handlers->dispatch_del;
|
||||
}
|
||||
|
||||
void
|
||||
qb_ipcs_service_context_set(qb_ipcs_service_t* s,
|
||||
void *context)
|
||||
{
|
||||
s->context = context;
|
||||
}
|
||||
|
||||
void *
|
||||
qb_ipcs_service_context_get(qb_ipcs_service_t* s)
|
||||
{
|
||||
return s->context;
|
||||
}
|
||||
|
||||
int32_t
|
||||
qb_ipcs_run(struct qb_ipcs_service *s)
|
||||
{
|
||||
@ -815,6 +828,15 @@ qb_ipcs_context_get(struct qb_ipcs_connection *c)
|
||||
return c->context;
|
||||
}
|
||||
|
||||
void *
|
||||
qb_ipcs_connection_service_context_get(qb_ipcs_connection_t *c)
|
||||
{
|
||||
if (c == NULL || c->service == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
return c->service->context;
|
||||
}
|
||||
|
||||
int32_t
|
||||
qb_ipcs_connection_stats_get(qb_ipcs_connection_t * c,
|
||||
struct qb_ipcs_connection_stats * stats,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user