aboutsummaryrefslogtreecommitdiff
path: root/src/core/pipe.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2016-12-22 20:52:45 -0800
committerGarrett D'Amore <garrett@damore.org>2016-12-22 20:52:45 -0800
commitee45cbf4498a3c1d1868469bdb0c767d66c278e4 (patch)
treeb9116256f12a54c90f92bf5cf215f3d4c8152126 /src/core/pipe.c
parent718de1828cc5b5256511c5b723360d499ae21c8f (diff)
downloadnng-ee45cbf4498a3c1d1868469bdb0c767d66c278e4.tar.gz
nng-ee45cbf4498a3c1d1868469bdb0c767d66c278e4.tar.bz2
nng-ee45cbf4498a3c1d1868469bdb0c767d66c278e4.zip
Endpoint dialer implemented.
Diffstat (limited to 'src/core/pipe.c')
-rw-r--r--src/core/pipe.c39
1 files changed, 28 insertions, 11 deletions
diff --git a/src/core/pipe.c b/src/core/pipe.c
index 58a31d7f..bf2e64fe 100644
--- a/src/core/pipe.c
+++ b/src/core/pipe.c
@@ -16,23 +16,23 @@
// nni_pipe_id returns the 32-bit pipe id, which can be used in backtraces.
uint32_t
-nni_pipe_id(nni_pipe * p)
+nni_pipe_id(nni_pipe *p)
{
return (p->p_id);
}
int
-nni_pipe_send(nni_pipe * p, nng_msg *msg)
+nni_pipe_send(nni_pipe *p, nng_msg *msg)
{
- return (p->p_ops.p_send(p->p_tran, msg));
+ return (p->p_ops.p_send(p->p_data, msg));
}
int
-nni_pipe_recv(nni_pipe * p, nng_msg **msgp)
+nni_pipe_recv(nni_pipe *p, nng_msg **msgp)
{
- return (p->p_ops.p_recv(p->p_tran, msgp));
+ return (p->p_ops.p_recv(p->p_data, msgp));
}
@@ -40,22 +40,39 @@ nni_pipe_recv(nni_pipe * p, nng_msg **msgp)
// subsequent attempts receive or send (including any waiting receive) will
// simply return NNG_ECLOSED.
void
-nni_pipe_close(nni_pipe * p)
+nni_pipe_close(nni_pipe *p)
{
- p->p_ops.p_close(p->p_tran);
+ p->p_ops.p_close(p->p_data);
}
uint16_t
-nni_pipe_peer(nni_pipe * p)
+nni_pipe_peer(nni_pipe *p)
{
- return (p->p_ops.p_peer(p->p_tran));
+ return (p->p_ops.p_peer(p->p_data));
}
void
-nni_pipe_destroy(nni_pipe * p)
+nni_pipe_destroy(nni_pipe *p)
{
- p->p_ops.p_destroy(p->p_tran);
+ if (p->p_data != NULL) {
+ p->p_ops.p_destroy(p->p_data);
+ }
nni_free(p, sizeof (*p));
}
+
+
+int
+nni_pipe_create(nni_pipe **pp, const nni_pipe_ops *ops)
+{
+ nni_pipe *p;
+
+ if ((p = nni_alloc(sizeof (*p))) == NULL) {
+ return (NNG_ENOMEM);
+ }
+ p->p_data = NULL;
+ p->p_ops = *ops;
+ p->p_id = nni_plat_nextid();
+ return (0);
+}