From 85dccbf083e3c6115c5e3757b8efb7aa069acab6 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Mon, 11 Jan 2021 23:01:33 -0800 Subject: fixes #808 Very slow PAIR performance compared to nanomsg This is only the pair v1 protocol. Pair v0 and polyamorous mode still have work to do. We probably won't "fix" the performance for poly mode since that's deprecated anyway. --- src/core/message.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'src/core/message.c') diff --git a/src/core/message.c b/src/core/message.c index 79031400..824fc079 100644 --- a/src/core/message.c +++ b/src/core/message.c @@ -1,5 +1,5 @@ // -// Copyright 2020 Staysail Systems, Inc. +// Copyright 2021 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV // // This software is supplied under the terms of the MIT License, a @@ -326,6 +326,12 @@ nni_msg_unique(nni_msg *m) return (m2); } +bool +nni_msg_shared(nni_msg *m) +{ + return (nni_atomic_get(&m->m_refcnt) > 1); +} + // nni_msg_pull_up ensures that the message is unique, and that any header // is merged with the message. The main purpose of doing this is to break // up the inproc binding -- protocols send messages to inproc with a @@ -575,6 +581,24 @@ nni_msg_header_append_u32(nni_msg *m, uint32_t val) m->m_header_len += sizeof(val); } +uint32_t +nni_msg_header_peek_u32(nni_msg *m) +{ + uint32_t val; + uint8_t *dst; + dst = (void *) m->m_header_buf; + NNI_GET32(dst, val); + return (val); +} + +void +nni_msg_header_poke_u32(nni_msg *m, uint32_t val) +{ + uint8_t *dst; + dst = (void *) m->m_header_buf; + NNI_PUT32(dst, val); +} + void nni_msg_clear(nni_msg *m) { -- cgit v1.2.3-70-g09d2