|
libqb
0.16.0
|
Server IPC API. More...
#include <stdlib.h>#include <sys/uio.h>#include <qb/qbipc_common.h>#include <qb/qbhdb.h>#include <qb/qbloop.h>
Data Structures | |
| struct | qb_ipcs_stats |
| struct | qb_ipcs_connection_stats |
| struct | qb_ipcs_connection_stats_2 |
| struct | qb_ipcs_poll_handlers |
| struct | qb_ipcs_service_handlers |
Typedefs | |
| typedef struct qb_ipcs_connection | qb_ipcs_connection_t |
| typedef struct qb_ipcs_service | qb_ipcs_service_t |
| typedef int32_t(* | qb_ipcs_dispatch_fn_t )(int32_t fd, int32_t revents, void *data) |
| typedef int32_t(* | qb_ipcs_dispatch_add_fn )(enum qb_loop_priority p, int32_t fd, int32_t events, void *data, qb_ipcs_dispatch_fn_t fn) |
| typedef int32_t(* | qb_ipcs_dispatch_mod_fn )(enum qb_loop_priority p, int32_t fd, int32_t events, void *data, qb_ipcs_dispatch_fn_t fn) |
| typedef int32_t(* | qb_ipcs_dispatch_del_fn )(int32_t fd) |
| typedef int32_t(* | qb_ipcs_job_add_fn )(enum qb_loop_priority p, void *data, qb_loop_job_dispatch_fn dispatch_fn) |
| typedef int32_t(* | qb_ipcs_connection_accept_fn )(qb_ipcs_connection_t *c, uid_t uid, gid_t gid) |
| This callback is to check wether you want to accept a new connection. | |
| typedef void(* | qb_ipcs_connection_created_fn )(qb_ipcs_connection_t *c) |
| This is called after a new connection has been created. | |
| typedef int32_t(* | qb_ipcs_connection_closed_fn )(qb_ipcs_connection_t *c) |
| This is called after a connection has been disconnected. | |
| typedef void(* | qb_ipcs_connection_destroyed_fn )(qb_ipcs_connection_t *c) |
| This is called just before a connection is freed. | |
| typedef int32_t(* | qb_ipcs_msg_process_fn )(qb_ipcs_connection_t *c, void *data, size_t size) |
| This is the message processing calback. | |
Enumerations | |
| enum | qb_ipcs_rate_limit { QB_IPCS_RATE_FAST, QB_IPCS_RATE_NORMAL, QB_IPCS_RATE_SLOW, QB_IPCS_RATE_OFF, QB_IPCS_RATE_OFF_2 } |
Functions | |
| qb_ipcs_service_t * | qb_ipcs_create (const char *name, int32_t service_id, enum qb_ipc_type type, struct qb_ipcs_service_handlers *handlers) |
| Create a new IPC server. | |
| void | qb_ipcs_ref (qb_ipcs_service_t *s) |
| Increase the reference counter on the service object. | |
| void | qb_ipcs_unref (qb_ipcs_service_t *s) |
| Decrease the reference counter on the service object. | |
| void | qb_ipcs_poll_handlers_set (qb_ipcs_service_t *s, struct qb_ipcs_poll_handlers *handlers) |
| Set your poll callbacks. | |
| void | qb_ipcs_service_context_set (qb_ipcs_service_t *s, void *context) |
| Associate a "user" pointer with this service. | |
| void * | qb_ipcs_service_context_get (qb_ipcs_service_t *s) |
| Get the context (set previously) | |
| int32_t | qb_ipcs_run (qb_ipcs_service_t *s) |
| run the new IPC server. | |
| void | qb_ipcs_destroy (qb_ipcs_service_t *s) |
| Destroy the IPC server. | |
| void | qb_ipcs_request_rate_limit (qb_ipcs_service_t *s, enum qb_ipcs_rate_limit rl) |
| Limit the incomming request rate. | |
| ssize_t | qb_ipcs_response_send (qb_ipcs_connection_t *c, const void *data, size_t size) |
| Send a response to a incomming request. | |
| ssize_t | qb_ipcs_response_sendv (qb_ipcs_connection_t *c, const struct iovec *iov, size_t iov_len) |
| Send a response to a incomming request. | |
| ssize_t | qb_ipcs_event_send (qb_ipcs_connection_t *c, const void *data, size_t size) |
| Send an asyncronous event message to the client. | |
| ssize_t | qb_ipcs_event_sendv (qb_ipcs_connection_t *c, const struct iovec *iov, size_t iov_len) |
| Send an asyncronous event message to the client. | |
| void | qb_ipcs_connection_ref (qb_ipcs_connection_t *c) |
| Increment the connection's reference counter. | |
| void | qb_ipcs_connection_unref (qb_ipcs_connection_t *c) |
| Decrement the connection's reference counter. | |
| void | qb_ipcs_disconnect (qb_ipcs_connection_t *c) |
| Disconnect from this client. | |
| int32_t | qb_ipcs_service_id_get (qb_ipcs_connection_t *c) |
| Get the service id related to this connection's service. | |
| void | qb_ipcs_context_set (qb_ipcs_connection_t *c, void *context) |
| Associate a "user" pointer with this connection. | |
| void * | qb_ipcs_context_get (qb_ipcs_connection_t *c) |
| Get the context (set previously) | |
| void * | qb_ipcs_connection_service_context_get (qb_ipcs_connection_t *c) |
| Get the context previously set on the service backing this connection. | |
| int32_t | qb_ipcs_connection_stats_get (qb_ipcs_connection_t *c, struct qb_ipcs_connection_stats *stats, int32_t clear_after_read) |
| Get the connection statistics. | |
| struct qb_ipcs_connection_stats_2 * | qb_ipcs_connection_stats_get_2 (qb_ipcs_connection_t *c, int32_t clear_after_read) |
| Get (and allocate) the connection statistics. | |
| int32_t | qb_ipcs_stats_get (qb_ipcs_service_t *pt, struct qb_ipcs_stats *stats, int32_t clear_after_read) |
| Get the service statistics. | |
| qb_ipcs_connection_t * | qb_ipcs_connection_first_get (qb_ipcs_service_t *pt) |
| Get the first connection. | |
| qb_ipcs_connection_t * | qb_ipcs_connection_next_get (qb_ipcs_service_t *pt, qb_ipcs_connection_t *current) |
| Get the next connection. | |
| void | qb_ipcs_connection_auth_set (qb_ipcs_connection_t *conn, uid_t uid, gid_t gid, mode_t mode) |
| Set the permissions on and shared memory files so that both processes can read and write to them. | |
Server IPC API.
| typedef int32_t(* qb_ipcs_connection_accept_fn)(qb_ipcs_connection_t *c, uid_t uid, gid_t gid) |
This callback is to check wether you want to accept a new connection.
The type of checks you should do are authentication, service availabilty or process resource constraints.
| typedef int32_t(* qb_ipcs_connection_closed_fn)(qb_ipcs_connection_t *c) |
This is called after a connection has been disconnected.
| typedef void(* qb_ipcs_connection_created_fn)(qb_ipcs_connection_t *c) |
This is called after a new connection has been created.
| typedef void(* qb_ipcs_connection_destroyed_fn)(qb_ipcs_connection_t *c) |
This is called just before a connection is freed.
| typedef struct qb_ipcs_connection qb_ipcs_connection_t |
| typedef int32_t(* qb_ipcs_dispatch_add_fn)(enum qb_loop_priority p, int32_t fd, int32_t events, void *data, qb_ipcs_dispatch_fn_t fn) |
| typedef int32_t(* qb_ipcs_dispatch_del_fn)(int32_t fd) |
| typedef int32_t(* qb_ipcs_dispatch_fn_t)(int32_t fd, int32_t revents, void *data) |
| typedef int32_t(* qb_ipcs_dispatch_mod_fn)(enum qb_loop_priority p, int32_t fd, int32_t events, void *data, qb_ipcs_dispatch_fn_t fn) |
| typedef int32_t(* qb_ipcs_job_add_fn)(enum qb_loop_priority p, void *data, qb_loop_job_dispatch_fn dispatch_fn) |
| typedef int32_t(* qb_ipcs_msg_process_fn)(qb_ipcs_connection_t *c, void *data, size_t size) |
This is the message processing calback.
It is called with the message data.
| typedef struct qb_ipcs_service qb_ipcs_service_t |
| enum qb_ipcs_rate_limit |
| void qb_ipcs_connection_auth_set | ( | qb_ipcs_connection_t * | conn, |
| uid_t | uid, | ||
| gid_t | gid, | ||
| mode_t | mode | ||
| ) |
Set the permissions on and shared memory files so that both processes can read and write to them.
| conn | connection instance |
| uid | the user id to set. |
| gid | the group id to set. |
| mode | the mode to set. |
| qb_ipcs_connection_t* qb_ipcs_connection_first_get | ( | qb_ipcs_service_t * | pt | ) |
Get the first connection.
| pt | service instance |
| qb_ipcs_connection_t* qb_ipcs_connection_next_get | ( | qb_ipcs_service_t * | pt, |
| qb_ipcs_connection_t * | current | ||
| ) |
Get the next connection.
| pt | service instance |
| current | current connection |
| void qb_ipcs_connection_ref | ( | qb_ipcs_connection_t * | c | ) |
Increment the connection's reference counter.
| c | connection instance |
| void* qb_ipcs_connection_service_context_get | ( | qb_ipcs_connection_t * | c | ) |
Get the context previously set on the service backing this connection.
| c | connection instance |
| int32_t qb_ipcs_connection_stats_get | ( | qb_ipcs_connection_t * | c, |
| struct qb_ipcs_connection_stats * | stats, | ||
| int32_t | clear_after_read | ||
| ) |
Get the connection statistics.
| stats | (out) the statistics structure |
| clear_after_read | clear stats after copying them into stats |
| c | connection instance |
|
read |
Get (and allocate) the connection statistics.
| clear_after_read | clear stats after copying them into stats |
| c | connection instance |
| NULL | if no memory or invalid connection |
| allocated | statistics structure (user must free it). |
| void qb_ipcs_connection_unref | ( | qb_ipcs_connection_t * | c | ) |
Decrement the connection's reference counter.
| c | connection instance |
| void* qb_ipcs_context_get | ( | qb_ipcs_connection_t * | c | ) |
Get the context (set previously)
| c | connection instance |
| void qb_ipcs_context_set | ( | qb_ipcs_connection_t * | c, |
| void * | context | ||
| ) |
Associate a "user" pointer with this connection.
| context | the point to associate with this connection. |
| c | connection instance |
| qb_ipcs_service_t* qb_ipcs_create | ( | const char * | name, |
| int32_t | service_id, | ||
| enum qb_ipc_type | type, | ||
| struct qb_ipcs_service_handlers * | handlers | ||
| ) |
Create a new IPC server.
| name | for clients to connect to. |
| service_id | an integer to associate with the service |
| type | transport type. |
| handlers | callbacks. |
| void qb_ipcs_destroy | ( | qb_ipcs_service_t * | s | ) |
| void qb_ipcs_disconnect | ( | qb_ipcs_connection_t * | c | ) |
Disconnect from this client.
| c | connection instance |
| ssize_t qb_ipcs_event_send | ( | qb_ipcs_connection_t * | c, |
| const void * | data, | ||
| size_t | size | ||
| ) |
Send an asyncronous event message to the client.
| c | connection instance |
| data | the message to send |
| size | the size of the message |
| ssize_t qb_ipcs_event_sendv | ( | qb_ipcs_connection_t * | c, |
| const struct iovec * | iov, | ||
| size_t | iov_len | ||
| ) |
Send an asyncronous event message to the client.
| c | connection instance |
| iov | the iovec struct that points to the message to send |
| iov_len | the number of iovecs. |
| void qb_ipcs_poll_handlers_set | ( | qb_ipcs_service_t * | s, |
| struct qb_ipcs_poll_handlers * | handlers | ||
| ) |
Set your poll callbacks.
| s | service instance |
| handlers | the handlers that you want ipcs to use. |
| void qb_ipcs_ref | ( | qb_ipcs_service_t * | s | ) |
Increase the reference counter on the service object.
| s | service instance |
| void qb_ipcs_request_rate_limit | ( | qb_ipcs_service_t * | s, |
| enum qb_ipcs_rate_limit | rl | ||
| ) |
Limit the incomming request rate.
| s | service instance |
| rl | the new rate |
| ssize_t qb_ipcs_response_send | ( | qb_ipcs_connection_t * | c, |
| const void * | data, | ||
| size_t | size | ||
| ) |
Send a response to a incomming request.
| c | connection instance |
| data | the message to send |
| size | the size of the message |
| ssize_t qb_ipcs_response_sendv | ( | qb_ipcs_connection_t * | c, |
| const struct iovec * | iov, | ||
| size_t | iov_len | ||
| ) |
Send a response to a incomming request.
| c | connection instance |
| iov | the iovec struct that points to the message to send |
| iov_len | the number of iovecs. |
| int32_t qb_ipcs_run | ( | qb_ipcs_service_t * | s | ) |
run the new IPC server.
| s | service instance |
| void* qb_ipcs_service_context_get | ( | qb_ipcs_service_t * | s | ) |
Get the context (set previously)
| s | service instance |
| void qb_ipcs_service_context_set | ( | qb_ipcs_service_t * | s, |
| void * | context | ||
| ) |
Associate a "user" pointer with this service.
| s | service instance |
| context | the pointer to associate with this service. |
| int32_t qb_ipcs_service_id_get | ( | qb_ipcs_connection_t * | c | ) |
Get the service id related to this connection's service.
(as passed into qb_ipcs_create()
| int32_t qb_ipcs_stats_get | ( | qb_ipcs_service_t * | pt, |
| struct qb_ipcs_stats * | stats, | ||
| int32_t | clear_after_read | ||
| ) |
Get the service statistics.
| stats | (out) the statistics structure |
| clear_after_read | clear stats after copying them into stats |
| pt | service instance |
| void qb_ipcs_unref | ( | qb_ipcs_service_t * | s | ) |
Decrease the reference counter on the service object.
| s | service instance |
1.8.3