From abab1392c11395d387e3072c4f5788d284846093 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Wed, 26 Feb 2020 00:22:11 -0800 Subject: 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. --- src/protocol/bus0/bus.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'src/protocol/bus0') 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)); -- cgit v1.2.3-70-g09d2