aboutsummaryrefslogtreecommitdiff
path: root/src/protocol/pipeline0/push.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2020-01-03 18:03:57 -0800
committerGarrett D'Amore <garrett@damore.org>2020-01-03 18:09:08 -0800
commitbcc3814b58e9b198344bdaf6e7a916a354841275 (patch)
tree795ce060fa8b4356bb4d17457abccdaf6fed8883 /src/protocol/pipeline0/push.c
parentd4cb4abccaa8a3bf319d19f97345c04ebd755053 (diff)
downloadnng-bcc3814b58e9b198344bdaf6e7a916a354841275.tar.gz
nng-bcc3814b58e9b198344bdaf6e7a916a354841275.tar.bz2
nng-bcc3814b58e9b198344bdaf6e7a916a354841275.zip
fixes #1104 move allocation of protocol objects to common core
fixes #1103 respondent could inline backtrace
Diffstat (limited to 'src/protocol/pipeline0/push.c')
-rw-r--r--src/protocol/pipeline0/push.c29
1 files changed, 9 insertions, 20 deletions
diff --git a/src/protocol/pipeline0/push.c b/src/protocol/pipeline0/push.c
index 1c0657a8..5a932ece 100644
--- a/src/protocol/pipeline0/push.c
+++ b/src/protocol/pipeline0/push.c
@@ -1,5 +1,5 @@
//
-// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech>
+// Copyright 2020 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
@@ -9,7 +9,6 @@
//
#include <stdlib.h>
-#include <string.h>
#include "core/nng_impl.h"
#include "nng/protocol/pipeline0/push.h"
@@ -50,24 +49,17 @@ struct push0_pipe {
};
static int
-push0_sock_init(void **sp, nni_sock *sock)
+push0_sock_init(void *arg, nni_sock *sock)
{
- push0_sock *s;
-
- if ((s = NNI_ALLOC_STRUCT(s)) == NULL) {
- return (NNG_ENOMEM);
- }
- s->uwq = nni_sock_sendq(sock);
- *sp = s;
+ push0_sock *s = arg;
+ s->uwq = nni_sock_sendq(sock);
return (0);
}
static void
push0_sock_fini(void *arg)
{
- push0_sock *s = arg;
-
- NNI_FREE_STRUCT(s);
+ NNI_ARG_UNUSED(arg);
}
static void
@@ -100,18 +92,14 @@ push0_pipe_fini(void *arg)
nni_aio_fini(p->aio_recv);
nni_aio_fini(p->aio_send);
nni_aio_fini(p->aio_getq);
- NNI_FREE_STRUCT(p);
}
static int
-push0_pipe_init(void **pp, nni_pipe *pipe, void *s)
+push0_pipe_init(void *arg, nni_pipe *pipe, void *s)
{
- push0_pipe *p;
+ push0_pipe *p = arg;
int rv;
- if ((p = NNI_ALLOC_STRUCT(p)) == NULL) {
- return (NNG_ENOMEM);
- }
if (((rv = nni_aio_init(&p->aio_recv, push0_recv_cb, p)) != 0) ||
((rv = nni_aio_init(&p->aio_send, push0_send_cb, p)) != 0) ||
((rv = nni_aio_init(&p->aio_getq, push0_getq_cb, p)) != 0)) {
@@ -121,7 +109,6 @@ push0_pipe_init(void **pp, nni_pipe *pipe, void *s)
NNI_LIST_NODE_INIT(&p->node);
p->pipe = pipe;
p->push = s;
- *pp = p;
return (0);
}
@@ -221,6 +208,7 @@ push0_sock_recv(void *arg, nni_aio *aio)
}
static nni_proto_pipe_ops push0_pipe_ops = {
+ .pipe_size = sizeof(push0_pipe),
.pipe_init = push0_pipe_init,
.pipe_fini = push0_pipe_fini,
.pipe_start = push0_pipe_start,
@@ -236,6 +224,7 @@ static nni_option push0_sock_options[] = {
};
static nni_proto_sock_ops push0_sock_ops = {
+ .sock_size = sizeof(push0_sock),
.sock_init = push0_sock_init,
.sock_fini = push0_sock_fini,
.sock_open = push0_sock_open,