aboutsummaryrefslogtreecommitdiff
path: root/src/protocol/reqrep0/xreq.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2018-04-20 20:52:32 -0700
committerGarrett D'Amore <garrett@damore.org>2018-04-24 15:06:33 -0700
commitfdefff742662ed4eb476bf19b9dda245f86bc406 (patch)
treea4e132716debd64e434478f8814f368db052cbc6 /src/protocol/reqrep0/xreq.c
parente0b47b12d3d1462d07c5038e4f34f5282eeec675 (diff)
downloadnng-fdefff742662ed4eb476bf19b9dda245f86bc406.tar.gz
nng-fdefff742662ed4eb476bf19b9dda245f86bc406.tar.bz2
nng-fdefff742662ed4eb476bf19b9dda245f86bc406.zip
fixes #342 Want Surveyor/Respondent context support
fixes #360 core should nng_aio_begin before nng_aio_finish_error fixes #361 nng_send_aio should check for NULL message fixes #362 nni_msgq does not signal pollable on certain events This adds support for contexts for both sides of the surveyor pattern. Prior to this commit, the raw mode was completely broken, and there were numerous other bugs found and fixed. This integration includes *much* deeper validation of this pattern. Some changes to the core and other patterns have been made, where it was obvioius that we could make such improvements. (The obviousness stemming from the fact that RESPONDENT in particular is very closely derived from REP.)
Diffstat (limited to 'src/protocol/reqrep0/xreq.c')
-rw-r--r--src/protocol/reqrep0/xreq.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/src/protocol/reqrep0/xreq.c b/src/protocol/reqrep0/xreq.c
index 5c1841b2..13ae7418 100644
--- a/src/protocol/reqrep0/xreq.c
+++ b/src/protocol/reqrep0/xreq.c
@@ -226,25 +226,21 @@ xreq0_recv_cb(void *arg)
// We yank 4 bytes from front of body, and move them to the header.
if (nni_msg_len(msg) < 4) {
- // Malformed message.
- goto malformed;
+ // Peer gave us garbage, so kick it.
+ nni_msg_free(msg);
+ nni_pipe_stop(p->pipe);
+ return;
}
id = nni_msg_trim_u32(msg);
if (nni_msg_header_append_u32(msg, id) != 0) {
- // Arguably we could just discard and carry on. But
- // dropping the connection is probably more helpful since
- // it lets the other side see that a problem occurred.
- // Plus it gives us a chance to reclaim some memory.
- goto malformed;
+ // Probably ENOMEM, discard and carry on.
+ nni_msg_free(msg);
+ nni_pipe_recv(p->pipe, p->aio_recv);
+ return;
}
nni_aio_set_msg(p->aio_putq, msg);
nni_msgq_aio_put(sock->urq, p->aio_putq);
- return;
-
-malformed:
- nni_msg_free(msg);
- nni_pipe_stop(p->pipe);
}
static void