aboutsummaryrefslogtreecommitdiff
path: root/src/protocol/pair0/pair.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2020-02-05 22:42:20 -0800
committerGarrett D'Amore <garrett@damore.org>2020-02-05 23:05:03 -0800
commit11335aa5584ef689c9335df3a97668fe62b8418c (patch)
treea150df7d28abc9d9953b6e3ef59176e942f02c28 /src/protocol/pair0/pair.c
parent40141b3f3891e86541544848f65ea57fef41cedd (diff)
downloadnng-11335aa5584ef689c9335df3a97668fe62b8418c.tar.gz
nng-11335aa5584ef689c9335df3a97668fe62b8418c.tar.bz2
nng-11335aa5584ef689c9335df3a97668fe62b8418c.zip
inline the pipe aios for pair0
Diffstat (limited to 'src/protocol/pair0/pair.c')
-rw-r--r--src/protocol/pair0/pair.c85
1 files changed, 40 insertions, 45 deletions
diff --git a/src/protocol/pair0/pair.c b/src/protocol/pair0/pair.c
index 730e5f5e..41f88c7c 100644
--- a/src/protocol/pair0/pair.c
+++ b/src/protocol/pair0/pair.c
@@ -9,7 +9,6 @@
//
#include <stdlib.h>
-#include <string.h>
#include "core/nng_impl.h"
#include "nng/protocol/pair0/pair.h"
@@ -46,10 +45,10 @@ struct pair0_sock {
struct pair0_pipe {
nni_pipe * npipe;
pair0_sock *psock;
- nni_aio * aio_send;
- nni_aio * aio_recv;
- nni_aio * aio_getq;
- nni_aio * aio_putq;
+ nni_aio aio_send;
+ nni_aio aio_recv;
+ nni_aio aio_getq;
+ nni_aio aio_putq;
};
static int
@@ -77,10 +76,10 @@ pair0_pipe_stop(void *arg)
{
pair0_pipe *p = arg;
- nni_aio_stop(p->aio_send);
- nni_aio_stop(p->aio_recv);
- nni_aio_stop(p->aio_putq);
- nni_aio_stop(p->aio_getq);
+ nni_aio_stop(&p->aio_send);
+ nni_aio_stop(&p->aio_recv);
+ nni_aio_stop(&p->aio_putq);
+ nni_aio_stop(&p->aio_getq);
}
static void
@@ -88,25 +87,21 @@ pair0_pipe_fini(void *arg)
{
pair0_pipe *p = arg;
- nni_aio_free(p->aio_send);
- nni_aio_free(p->aio_recv);
- nni_aio_free(p->aio_putq);
- nni_aio_free(p->aio_getq);
+ nni_aio_fini(&p->aio_send);
+ nni_aio_fini(&p->aio_recv);
+ nni_aio_fini(&p->aio_putq);
+ nni_aio_fini(&p->aio_getq);
}
static int
pair0_pipe_init(void *arg, nni_pipe *npipe, void *psock)
{
pair0_pipe *p = arg;
- int rv;
-
- if (((rv = nni_aio_alloc(&p->aio_send, pair0_send_cb, p)) != 0) ||
- ((rv = nni_aio_alloc(&p->aio_recv, pair0_recv_cb, p)) != 0) ||
- ((rv = nni_aio_alloc(&p->aio_getq, pair0_getq_cb, p)) != 0) ||
- ((rv = nni_aio_alloc(&p->aio_putq, pair0_putq_cb, p)) != 0)) {
- pair0_pipe_fini(p);
- return (rv);
- }
+
+ nni_aio_init(&p->aio_send, pair0_send_cb, p);
+ nni_aio_init(&p->aio_recv, pair0_recv_cb, p);
+ nni_aio_init(&p->aio_getq, pair0_getq_cb, p);
+ nni_aio_init(&p->aio_putq, pair0_putq_cb, p);
p->npipe = npipe;
p->psock = psock;
@@ -134,8 +129,8 @@ pair0_pipe_start(void *arg)
// Schedule a getq on the upper, and a read from the pipe.
// Each of these also sets up another hold on the pipe itself.
- nni_msgq_aio_get(s->uwq, p->aio_getq);
- nni_pipe_recv(p->npipe, p->aio_recv);
+ nni_msgq_aio_get(s->uwq, &p->aio_getq);
+ nni_pipe_recv(p->npipe, &p->aio_recv);
return (0);
}
@@ -146,10 +141,10 @@ pair0_pipe_close(void *arg)
pair0_pipe *p = arg;
pair0_sock *s = p->psock;
- nni_aio_close(p->aio_send);
- nni_aio_close(p->aio_recv);
- nni_aio_close(p->aio_putq);
- nni_aio_close(p->aio_getq);
+ nni_aio_close(&p->aio_send);
+ nni_aio_close(&p->aio_recv);
+ nni_aio_close(&p->aio_putq);
+ nni_aio_close(&p->aio_getq);
nni_mtx_lock(&s->mtx);
if (s->ppipe == p) {
@@ -165,17 +160,17 @@ pair0_recv_cb(void *arg)
pair0_sock *s = p->psock;
nni_msg * msg;
- if (nni_aio_result(p->aio_recv) != 0) {
+ if (nni_aio_result(&p->aio_recv) != 0) {
nni_pipe_close(p->npipe);
return;
}
- msg = nni_aio_get_msg(p->aio_recv);
- nni_aio_set_msg(p->aio_putq, msg);
- nni_aio_set_msg(p->aio_recv, NULL);
+ msg = nni_aio_get_msg(&p->aio_recv);
+ nni_aio_set_msg(&p->aio_putq, msg);
+ nni_aio_set_msg(&p->aio_recv, NULL);
nni_msg_set_pipe(msg, nni_pipe_id(p->npipe));
- nni_msgq_aio_put(s->urq, p->aio_putq);
+ nni_msgq_aio_put(s->urq, &p->aio_putq);
}
static void
@@ -183,13 +178,13 @@ pair0_putq_cb(void *arg)
{
pair0_pipe *p = arg;
- if (nni_aio_result(p->aio_putq) != 0) {
- nni_msg_free(nni_aio_get_msg(p->aio_putq));
- nni_aio_set_msg(p->aio_putq, NULL);
+ if (nni_aio_result(&p->aio_putq) != 0) {
+ nni_msg_free(nni_aio_get_msg(&p->aio_putq));
+ nni_aio_set_msg(&p->aio_putq, NULL);
nni_pipe_close(p->npipe);
return;
}
- nni_pipe_recv(p->npipe, p->aio_recv);
+ nni_pipe_recv(p->npipe, &p->aio_recv);
}
static void
@@ -197,14 +192,14 @@ pair0_getq_cb(void *arg)
{
pair0_pipe *p = arg;
- if (nni_aio_result(p->aio_getq) != 0) {
+ if (nni_aio_result(&p->aio_getq) != 0) {
nni_pipe_close(p->npipe);
return;
}
- nni_aio_set_msg(p->aio_send, nni_aio_get_msg(p->aio_getq));
- nni_aio_set_msg(p->aio_getq, NULL);
- nni_pipe_send(p->npipe, p->aio_send);
+ nni_aio_set_msg(&p->aio_send, nni_aio_get_msg(&p->aio_getq));
+ nni_aio_set_msg(&p->aio_getq, NULL);
+ nni_pipe_send(p->npipe, &p->aio_send);
}
static void
@@ -213,14 +208,14 @@ pair0_send_cb(void *arg)
pair0_pipe *p = arg;
pair0_sock *s = p->psock;
- if (nni_aio_result(p->aio_send) != 0) {
- nni_msg_free(nni_aio_get_msg(p->aio_send));
- nni_aio_set_msg(p->aio_send, NULL);
+ if (nni_aio_result(&p->aio_send) != 0) {
+ nni_msg_free(nni_aio_get_msg(&p->aio_send));
+ nni_aio_set_msg(&p->aio_send, NULL);
nni_pipe_close(p->npipe);
return;
}
- nni_msgq_aio_get(s->uwq, p->aio_getq);
+ nni_msgq_aio_get(s->uwq, &p->aio_getq);
}
static void