From 59a4b69c7989ac4fef1645f929abfa91b884215b Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Fri, 6 Jan 2017 10:07:19 -0800 Subject: Fixes for PUB/SUB. This fixes several issues, and brings PUB/SUB to operational correctness. Included is test code to verify that. --- src/protocol/pubsub/sub.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/protocol/pubsub/sub.c') diff --git a/src/protocol/pubsub/sub.c b/src/protocol/pubsub/sub.c index 1243ca47..19c06aa0 100644 --- a/src/protocol/pubsub/sub.c +++ b/src/protocol/pubsub/sub.c @@ -200,6 +200,7 @@ nni_sub_subscribe(nni_sub_sock *sub, const void *buf, size_t sz) } NNI_LIST_NODE_INIT(&newtopic->node); newtopic->len = sz; + memcpy(newtopic->buf, buf, sz); if (topic != NULL) { nni_list_insert_before(&sub->topics, newtopic, topic); } else { @@ -306,6 +307,7 @@ nni_sub_recvfilter(void *arg, nni_msg *msg) body = nni_msg_body(msg); len = nni_msg_len(msg); + match = 0; // Check to see if the message matches one of our subscriptions. NNI_LIST_FOREACH (&sub->topics, topic) { if (len >= topic->len) { @@ -329,7 +331,7 @@ nni_sub_recvfilter(void *arg, nni_msg *msg) nni_msg_free(msg); return (NULL); } - return (0); + return (msg); } -- cgit v1.2.3-70-g09d2