summaryrefslogtreecommitdiff
path: root/src/core/message.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2021-01-11 23:01:33 -0800
committerGarrett D'Amore <garrett@damore.org>2021-01-18 17:50:35 -0800
commit85dccbf083e3c6115c5e3757b8efb7aa069acab6 (patch)
treeb82ed18a069e3efd199efac6005e6f4a24d98649 /src/core/message.c
parent35533f4b968fc14b80a085e0246aa3074c1dec6f (diff)
downloadnng-85dccbf083e3c6115c5e3757b8efb7aa069acab6.tar.gz
nng-85dccbf083e3c6115c5e3757b8efb7aa069acab6.tar.bz2
nng-85dccbf083e3c6115c5e3757b8efb7aa069acab6.zip
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.
Diffstat (limited to 'src/core/message.c')
-rw-r--r--src/core/message.c26
1 files changed, 25 insertions, 1 deletions
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. <info@staysail.tech>
+// Copyright 2021 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
//
// 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)
{