aboutsummaryrefslogtreecommitdiff
path: root/src/protocol/pipeline0
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2018-04-04 12:37:34 -0700
committerGarrett D'Amore <garrett@damore.org>2018-04-04 13:13:24 -0700
commit45f455064b5704f3d5ed8ecf9f197a18fe72ee59 (patch)
tree76a626029f3a5a818b113b7e4342efaf6220a03f /src/protocol/pipeline0
parent505a9bce029e51540739c853a6c9eef0ecfb2e90 (diff)
downloadnng-45f455064b5704f3d5ed8ecf9f197a18fe72ee59.tar.gz
nng-45f455064b5704f3d5ed8ecf9f197a18fe72ee59.tar.bz2
nng-45f455064b5704f3d5ed8ecf9f197a18fe72ee59.zip
fixes #331 replace NNG_OPT_RAW option with constructor
This makes the raw mode something that is immutable, determined at socket construction. This is an enabling change for the separate context support coming soon. As a result, this is an API breaking change for users of the raw mode option (NNG_OPT_RAW). There aren't many of them out there. Cooked mode is entirely unaffected. There are changes to tests and documentation included.
Diffstat (limited to 'src/protocol/pipeline0')
-rw-r--r--src/protocol/pipeline0/pull.c36
-rw-r--r--src/protocol/pipeline0/pull.h9
-rw-r--r--src/protocol/pipeline0/push.c37
-rw-r--r--src/protocol/pipeline0/push.h9
4 files changed, 44 insertions, 47 deletions
diff --git a/src/protocol/pipeline0/pull.c b/src/protocol/pipeline0/pull.c
index 9aa7bea9..c5017d50 100644
--- a/src/protocol/pipeline0/pull.c
+++ b/src/protocol/pipeline0/pull.c
@@ -53,7 +53,6 @@ pull0_sock_init(void **sp, nni_sock *sock)
if ((s = NNI_ALLOC_STRUCT(s)) == NULL) {
return (NNG_ENOMEM);
}
- s->raw = false;
s->urq = nni_sock_recvq(sock);
*sp = s;
@@ -180,20 +179,6 @@ pull0_sock_close(void *arg)
NNI_ARG_UNUSED(arg);
}
-static int
-pull0_sock_setopt_raw(void *arg, const void *buf, size_t sz, int typ)
-{
- pull0_sock *s = arg;
- return (nni_copyin_bool(&s->raw, buf, sz, typ));
-}
-
-static int
-pull0_sock_getopt_raw(void *arg, void *buf, size_t *szp, int typ)
-{
- pull0_sock *s = arg;
- return (nni_copyout_bool(s->raw, buf, szp, typ));
-}
-
static void
pull0_sock_send(void *arg, nni_aio *aio)
{
@@ -217,12 +202,6 @@ static nni_proto_pipe_ops pull0_pipe_ops = {
};
static nni_proto_sock_option pull0_sock_options[] = {
- {
- .pso_name = NNG_OPT_RAW,
- .pso_type = NNI_TYPE_BOOL,
- .pso_getopt = pull0_sock_getopt_raw,
- .pso_setopt = pull0_sock_setopt_raw,
- },
// terminate list
{
.pso_name = NULL,
@@ -248,8 +227,23 @@ static nni_proto pull0_proto = {
.proto_sock_ops = &pull0_sock_ops,
};
+static nni_proto pull0_proto_raw = {
+ .proto_version = NNI_PROTOCOL_VERSION,
+ .proto_self = { NNI_PROTO_PULL_V0, "pull" },
+ .proto_peer = { NNI_PROTO_PUSH_V0, "push" },
+ .proto_flags = NNI_PROTO_FLAG_RCV | NNI_PROTO_FLAG_RAW,
+ .proto_pipe_ops = &pull0_pipe_ops,
+ .proto_sock_ops = &pull0_sock_ops,
+};
+
int
nng_pull0_open(nng_socket *sidp)
{
return (nni_proto_open(sidp, &pull0_proto));
}
+
+int
+nng_pull0_open_raw(nng_socket *sidp)
+{
+ return (nni_proto_open(sidp, &pull0_proto_raw));
+}
diff --git a/src/protocol/pipeline0/pull.h b/src/protocol/pipeline0/pull.h
index 75bded03..1c5d63e3 100644
--- a/src/protocol/pipeline0/pull.h
+++ b/src/protocol/pipeline0/pull.h
@@ -1,6 +1,6 @@
//
-// Copyright 2017 Garrett D'Amore <garrett@damore.org>
-// Copyright 2017 Capitar IT Group BV <info@capitar.com>
+// Copyright 2018 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
// copy of which should be located in the distribution where this
@@ -16,11 +16,16 @@ extern "C" {
#endif
NNG_DECL int nng_pull0_open(nng_socket *);
+NNG_DECL int nng_pull0_open_raw(nng_socket *);
#ifndef nng_pull_open
#define nng_pull_open nng_pull0_open
#endif
+#ifndef nng_pull_open_raw
+#define nng_pull_open_raw nng_pull0_open_raw
+#endif
+
#ifdef __cplusplus
}
#endif
diff --git a/src/protocol/pipeline0/push.c b/src/protocol/pipeline0/push.c
index 8c8fa13e..2ad657b6 100644
--- a/src/protocol/pipeline0/push.c
+++ b/src/protocol/pipeline0/push.c
@@ -36,7 +36,6 @@ static void push0_getq_cb(void *);
// push0_sock is our per-socket protocol private structure.
struct push0_sock {
nni_msgq *uwq;
- bool raw;
};
// push0_pipe is our per-pipe protocol private structure.
@@ -58,7 +57,6 @@ push0_sock_init(void **sp, nni_sock *sock)
if ((s = NNI_ALLOC_STRUCT(s)) == NULL) {
return (NNG_ENOMEM);
}
- s->raw = false;
s->uwq = nni_sock_sendq(sock);
*sp = s;
return (0);
@@ -197,20 +195,6 @@ push0_getq_cb(void *arg)
nni_pipe_send(p->pipe, p->aio_send);
}
-static int
-push0_sock_setopt_raw(void *arg, const void *buf, size_t sz, int typ)
-{
- push0_sock *s = arg;
- return (nni_copyin_bool(&s->raw, buf, sz, typ));
-}
-
-static int
-push0_sock_getopt_raw(void *arg, void *buf, size_t *szp, int typ)
-{
- push0_sock *s = arg;
- return (nni_copyout_bool(s->raw, buf, szp, typ));
-}
-
static void
push0_sock_send(void *arg, nni_aio *aio)
{
@@ -234,12 +218,6 @@ static nni_proto_pipe_ops push0_pipe_ops = {
};
static nni_proto_sock_option push0_sock_options[] = {
- {
- .pso_name = NNG_OPT_RAW,
- .pso_type = NNI_TYPE_BOOL,
- .pso_getopt = push0_sock_getopt_raw,
- .pso_setopt = push0_sock_setopt_raw,
- },
// terminate list
{
.pso_name = NULL,
@@ -265,8 +243,23 @@ static nni_proto push0_proto = {
.proto_sock_ops = &push0_sock_ops,
};
+static nni_proto push0_proto_raw = {
+ .proto_version = NNI_PROTOCOL_VERSION,
+ .proto_self = { NNI_PROTO_PUSH_V0, "push" },
+ .proto_peer = { NNI_PROTO_PULL_V0, "pull" },
+ .proto_flags = NNI_PROTO_FLAG_SND | NNI_PROTO_FLAG_RAW,
+ .proto_pipe_ops = &push0_pipe_ops,
+ .proto_sock_ops = &push0_sock_ops,
+};
+
int
nng_push0_open(nng_socket *sidp)
{
return (nni_proto_open(sidp, &push0_proto));
}
+
+int
+nng_push0_open_raw(nng_socket *sidp)
+{
+ return (nni_proto_open(sidp, &push0_proto_raw));
+}
diff --git a/src/protocol/pipeline0/push.h b/src/protocol/pipeline0/push.h
index c7303b92..a1384e0a 100644
--- a/src/protocol/pipeline0/push.h
+++ b/src/protocol/pipeline0/push.h
@@ -1,6 +1,6 @@
//
-// Copyright 2017 Garrett D'Amore <garrett@damore.org>
-// Copyright 2017 Capitar IT Group BV <info@capitar.com>
+// Copyright 2018 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
// copy of which should be located in the distribution where this
@@ -16,11 +16,16 @@ extern "C" {
#endif
NNG_DECL int nng_push0_open(nng_socket *);
+NNG_DECL int nng_push0_open_raw(nng_socket *);
#ifndef nng_push_open
#define nng_push_open nng_push0_open
#endif
+#ifndef nng_push_open_raw
+#define nng_push_open_raw nng_push0_open_raw
+#endif
+
#ifdef __cplusplus
}
#endif