aboutsummaryrefslogtreecommitdiff
path: root/src/protocol/bus0
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2020-02-26 00:22:11 -0800
committerGarrett D'Amore <garrett@damore.org>2020-02-26 20:48:22 -0800
commitabab1392c11395d387e3072c4f5788d284846093 (patch)
treedbb1ecb2b166338496981c7d8e3e9e16b977b995 /src/protocol/bus0
parent6a59b15fba1085432c4c18952680e14d80dd134a (diff)
downloadnng-abab1392c11395d387e3072c4f5788d284846093.tar.gz
nng-abab1392c11395d387e3072c4f5788d284846093.tar.bz2
nng-abab1392c11395d387e3072c4f5788d284846093.zip
fixes #1171 message header could be inlined in the message structure
This uses a maximum 64-byte header and should avoid allocations and cache misses, leading to a small performance boost overall.
Diffstat (limited to 'src/protocol/bus0')
-rw-r--r--src/protocol/bus0/bus.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/protocol/bus0/bus.c b/src/protocol/bus0/bus.c
index c409292e..9a610ac6 100644
--- a/src/protocol/bus0/bus.c
+++ b/src/protocol/bus0/bus.c
@@ -99,7 +99,8 @@ bus0_sock_init_raw(void *arg, nni_sock *nsock)
NNI_LIST_INIT(&s->pipes, bus0_pipe, node);
nni_mtx_init(&s->mtx);
- if ((rv = nni_aio_alloc(&s->aio_getq, bus0_sock_getq_cb_raw, s)) != 0) {
+ if ((rv = nni_aio_alloc(&s->aio_getq, bus0_sock_getq_cb_raw, s)) !=
+ 0) {
bus0_sock_fini(s);
return (rv);
}
@@ -257,13 +258,8 @@ bus0_pipe_recv_cb(void *arg)
}
msg = nni_aio_get_msg(p->aio_recv);
- if (s->raw &&
- (nni_msg_header_insert_u32(msg, nni_pipe_id(p->npipe)) != 0)) {
- // XXX: bump a nomemory stat
- nni_msg_free(msg);
- nni_aio_set_msg(p->aio_recv, NULL);
- nni_pipe_close(p->npipe);
- return;
+ if (s->raw) {
+ nni_msg_header_append_u32(msg, nni_pipe_id(p->npipe));
}
nni_msg_set_pipe(msg, nni_pipe_id(p->npipe));