summaryrefslogtreecommitdiff
path: root/src/sp
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2021-12-25 13:14:26 -0800
committerGarrett D'Amore <garrett@damore.org>2021-12-25 13:14:26 -0800
commit57e5c8bb2ee122c30fa14127c3b969dc858491c0 (patch)
tree7c95640e8360c3d67d6967791b24a16b00414a5d /src/sp
parentbeb8eb05310ac945ede357e2e57152f0d71e38ed (diff)
downloadnng-57e5c8bb2ee122c30fa14127c3b969dc858491c0.tar.gz
nng-57e5c8bb2ee122c30fa14127c3b969dc858491c0.tar.bz2
nng-57e5c8bb2ee122c30fa14127c3b969dc858491c0.zip
Pollables can be completely inline.
This eliminates more failure paths, and brings us still closer to eliminating the possibility of failure during socket init.
Diffstat (limited to 'src/sp')
-rw-r--r--src/sp/protocol/pubsub0/pub.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/sp/protocol/pubsub0/pub.c b/src/sp/protocol/pubsub0/pub.c
index e3d4f16a..cfc3ed6d 100644
--- a/src/sp/protocol/pubsub0/pub.c
+++ b/src/sp/protocol/pubsub0/pub.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
@@ -40,7 +40,7 @@ struct pub0_sock {
nni_mtx mtx;
bool closed;
size_t sendbuf;
- nni_pollable *sendable;
+ nni_pollable sendable;
};
// pub0_pipe is our per-pipe protocol private structure.
@@ -60,7 +60,7 @@ pub0_sock_fini(void *arg)
{
pub0_sock *s = arg;
- nni_pollable_free(s->sendable);
+ nni_pollable_fini(&s->sendable);
nni_mtx_fini(&s->mtx);
}
@@ -68,12 +68,9 @@ static int
pub0_sock_init(void *arg, nni_sock *nsock)
{
pub0_sock *sock = arg;
- int rv;
NNI_ARG_UNUSED(nsock);
- if ((rv = nni_pollable_alloc(&sock->sendable)) != 0) {
- return (rv);
- }
+ nni_pollable_init(&sock->sendable);
nni_mtx_init(&sock->mtx);
NNI_LIST_INIT(&sock->pipes, pub0_pipe, node);
sock->sendbuf = 16; // fairly arbitrary
@@ -267,8 +264,8 @@ pub0_sock_get_sendfd(void *arg, void *buf, size_t *szp, nni_type t)
int rv;
nni_mtx_lock(&sock->mtx);
// PUB sockets are *always* writable.
- nni_pollable_raise(sock->sendable);
- rv = nni_pollable_getfd(sock->sendable, &fd);
+ nni_pollable_raise(&sock->sendable);
+ rv = nni_pollable_getfd(&sock->sendable, &fd);
nni_mtx_unlock(&sock->mtx);
if (rv == 0) {