aboutsummaryrefslogtreecommitdiff
path: root/src/protocol/pubsub0/pub.c
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/pubsub0/pub.c
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/pubsub0/pub.c')
-rw-r--r--src/protocol/pubsub0/pub.c37
1 files changed, 15 insertions, 22 deletions
diff --git a/src/protocol/pubsub0/pub.c b/src/protocol/pubsub0/pub.c
index aaa22801..45f4b7d9 100644
--- a/src/protocol/pubsub0/pub.c
+++ b/src/protocol/pubsub0/pub.c
@@ -40,7 +40,6 @@ static void pub0_pipe_fini(void *);
// pub0_sock is our per-socket protocol private structure.
struct pub0_sock {
nni_msgq *uwq;
- bool raw;
nni_aio * aio_getq;
nni_list pipes;
nni_mtx mtx;
@@ -83,7 +82,6 @@ pub0_sock_init(void **sp, nni_sock *sock)
return (rv);
}
- s->raw = false;
NNI_LIST_INIT(&s->pipes, pub0_pipe, node);
s->uwq = nni_sock_sendq(sock);
@@ -273,20 +271,6 @@ pub0_pipe_send_cb(void *arg)
nni_msgq_aio_get(p->sendq, p->aio_getq);
}
-static int
-pub0_sock_setopt_raw(void *arg, const void *buf, size_t sz, int typ)
-{
- pub0_sock *s = arg;
- return (nni_copyin_bool(&s->raw, buf, sz, typ));
-}
-
-static int
-pub0_sock_getopt_raw(void *arg, void *buf, size_t *szp, int typ)
-{
- pub0_sock *s = arg;
- return (nni_copyout_bool(s->raw, buf, szp, typ));
-}
-
static void
pub0_sock_recv(void *arg, nni_aio *aio)
{
@@ -310,12 +294,6 @@ static nni_proto_pipe_ops pub0_pipe_ops = {
};
static nni_proto_sock_option pub0_sock_options[] = {
- {
- .pso_name = NNG_OPT_RAW,
- .pso_type = NNI_TYPE_BOOL,
- .pso_getopt = pub0_sock_getopt_raw,
- .pso_setopt = pub0_sock_setopt_raw,
- },
// terminate list
{
.pso_name = NULL,
@@ -341,8 +319,23 @@ static nni_proto pub0_proto = {
.proto_pipe_ops = &pub0_pipe_ops,
};
+static nni_proto pub0_proto_raw = {
+ .proto_version = NNI_PROTOCOL_VERSION,
+ .proto_self = { NNI_PROTO_PUB_V0, "pub" },
+ .proto_peer = { NNI_PROTO_SUB_V0, "sub" },
+ .proto_flags = NNI_PROTO_FLAG_SND | NNI_PROTO_FLAG_RAW,
+ .proto_sock_ops = &pub0_sock_ops,
+ .proto_pipe_ops = &pub0_pipe_ops,
+};
+
int
nng_pub0_open(nng_socket *sidp)
{
return (nni_proto_open(sidp, &pub0_proto));
}
+
+int
+nng_pub0_open_raw(nng_socket *sidp)
+{
+ return (nni_proto_open(sidp, &pub0_proto_raw));
+}