Skip to content

Commit

Permalink
Merge pull request #100 from davidvossel/server_side_buf_limit
Browse files Browse the repository at this point in the history
Low: example: Update client/server example to use server enforced buffer...
  • Loading branch information
davidvossel committed Nov 18, 2013
2 parents c3b4143 + ecff303 commit b09473f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
10 changes: 7 additions & 3 deletions examples/ipcclient.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -233,5 +236,6 @@ main(int argc, char *argv[])
}

qb_ipcc_disconnect(conn);
free(data);
return EXIT_SUCCESS;
}
5 changes: 5 additions & 0 deletions examples/ipcserver.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit b09473f

Please sign in to comment.