mirror of
https://salsa.debian.org/ha-team/libqb
synced 2026-08-18 09:53:17 +00:00
Low: example: Update client/server example to use server enforced buffer size
This commit is contained in:
parent
d17d6b3a06
commit
ecff303865
@ -31,8 +31,7 @@ static int32_t use_events = QB_FALSE;
|
||||
static int alarm_notice;
|
||||
static qb_util_stopwatch_t *sw;
|
||||
#define ONE_MEG 1048576
|
||||
#define MAX_MSG_SIZE ONE_MEG
|
||||
static char data[ONE_MEG];
|
||||
static char *data;
|
||||
|
||||
struct my_req {
|
||||
struct qb_ipc_request_header hdr;
|
||||
@ -220,11 +219,15 @@ main(int argc, char *argv[])
|
||||
qb_log_format_set(QB_LOG_STDERR, "%f:%l [%p] %b");
|
||||
qb_log_ctl(QB_LOG_STDERR, QB_LOG_CONF_ENABLED, QB_TRUE);
|
||||
|
||||
conn = qb_ipcc_connect("ipcserver", MAX_MSG_SIZE);
|
||||
/* Our example server is enforcing a buffer size minimum,
|
||||
* so the client does not need to be concerned with setting
|
||||
* the buffer size */
|
||||
conn = qb_ipcc_connect("ipcserver", 0);
|
||||
if (conn == NULL) {
|
||||
perror("qb_ipcc_connect");
|
||||
exit(1);
|
||||
}
|
||||
data = calloc(1, qb_ipcc_get_buffer_size(conn));
|
||||
|
||||
if (do_benchmark) {
|
||||
do_throughput_benchmark(conn);
|
||||
@ -233,5 +236,6 @@ main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
qb_ipcc_disconnect(conn);
|
||||
free(data);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@ -33,6 +33,8 @@ static GMainLoop *glib_loop;
|
||||
static qb_array_t *gio_map;
|
||||
#endif /* HAVE_GLIB */
|
||||
|
||||
#define ONE_MEG 1048576
|
||||
|
||||
static int32_t use_glib = QB_FALSE;
|
||||
static int32_t use_events = QB_FALSE;
|
||||
static qb_loop_t *bms_loop;
|
||||
@ -353,6 +355,9 @@ main(int32_t argc, char *argv[])
|
||||
qb_perror(LOG_ERR, "qb_ipcs_create");
|
||||
exit(1);
|
||||
}
|
||||
/* This forces the clients to use a minimum buffer size */
|
||||
qb_ipcs_enforce_buffer_size(s1, ONE_MEG);
|
||||
|
||||
if (!use_glib) {
|
||||
bms_loop = qb_loop_create();
|
||||
qb_ipcs_poll_handlers_set(s1, &ph);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user