aboutsummaryrefslogtreecommitdiff
path: root/src/protocol/pubsub
diff options
context:
space:
mode:
Diffstat (limited to 'src/protocol/pubsub')
-rw-r--r--src/protocol/pubsub/pub.c21
-rw-r--r--src/protocol/pubsub/sub.c26
2 files changed, 41 insertions, 6 deletions
diff --git a/src/protocol/pubsub/pub.c b/src/protocol/pubsub/pub.c
index e32f179a..161a5d79 100644
--- a/src/protocol/pubsub/pub.c
+++ b/src/protocol/pubsub/pub.c
@@ -98,6 +98,14 @@ nni_pub_sock_open(void *arg)
}
static void
+nni_pub_sock_close(void *arg)
+{
+ nni_pub_sock *pub = arg;
+
+ nni_aio_cancel(&pub->aio_getq, NNG_ECLOSED);
+}
+
+static void
nni_pub_pipe_fini(void *arg)
{
nni_pub_pipe *pp = arg;
@@ -319,15 +327,22 @@ nni_proto_sock_ops nni_pub_sock_ops = {
.sock_init = nni_pub_sock_init,
.sock_fini = nni_pub_sock_fini,
.sock_open = nni_pub_sock_open,
+ .sock_close = nni_pub_sock_close,
.sock_setopt = nni_pub_sock_setopt,
.sock_getopt = nni_pub_sock_getopt,
};
nni_proto nni_pub_proto = {
- .proto_self = NNG_PROTO_PUB,
- .proto_peer = NNG_PROTO_SUB,
- .proto_name = "pub",
+ .proto_version = NNI_PROTOCOL_VERSION,
+ .proto_self = { NNG_PROTO_PUB_V0, "pub" },
+ .proto_peer = { NNG_PROTO_SUB_V0, "sub" },
.proto_flags = NNI_PROTO_FLAG_SND,
.proto_sock_ops = &nni_pub_sock_ops,
.proto_pipe_ops = &nni_pub_pipe_ops,
};
+
+int
+nng_pub0_open(nng_socket *sidp)
+{
+ return (nni_proto_open(sidp, &nni_pub_proto));
+}
diff --git a/src/protocol/pubsub/sub.c b/src/protocol/pubsub/sub.c
index 03d76e2d..53f01e0f 100644
--- a/src/protocol/pubsub/sub.c
+++ b/src/protocol/pubsub/sub.c
@@ -79,6 +79,18 @@ nni_sub_sock_fini(void *arg)
NNI_FREE_STRUCT(sub);
}
+static void
+nni_sub_sock_open(void *arg)
+{
+ NNI_ARG_UNUSED(arg);
+}
+
+static void
+nni_sub_sock_close(void *arg)
+{
+ NNI_ARG_UNUSED(arg);
+}
+
static int
nni_sub_pipe_init(void **spp, nni_pipe *pipe, void *ssock)
{
@@ -330,16 +342,24 @@ static nni_proto_pipe_ops nni_sub_pipe_ops = {
static nni_proto_sock_ops nni_sub_sock_ops = {
.sock_init = nni_sub_sock_init,
.sock_fini = nni_sub_sock_fini,
+ .sock_open = nni_sub_sock_open,
+ .sock_close = nni_sub_sock_close,
.sock_setopt = nni_sub_sock_setopt,
.sock_getopt = nni_sub_sock_getopt,
.sock_rfilter = nni_sub_sock_rfilter,
};
nni_proto nni_sub_proto = {
- .proto_self = NNG_PROTO_SUB,
- .proto_peer = NNG_PROTO_PUB,
- .proto_name = "sub",
+ .proto_version = NNI_PROTOCOL_VERSION,
+ .proto_self = { NNG_PROTO_SUB_V0, "sub" },
+ .proto_peer = { NNG_PROTO_PUB_V0, "pub" },
.proto_flags = NNI_PROTO_FLAG_RCV,
.proto_sock_ops = &nni_sub_sock_ops,
.proto_pipe_ops = &nni_sub_pipe_ops,
};
+
+int
+nng_sub0_open(nng_socket *sidp)
+{
+ return (nni_proto_open(sidp, &nni_sub_proto));
+}