aboutsummaryrefslogtreecommitdiff
path: root/src/nng.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/nng.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/nng.c')
-rw-r--r--src/nng.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/src/nng.c b/src/nng.c
index 9eb33f50..fb374dde 100644
--- a/src/nng.c
+++ b/src/nng.c
@@ -198,7 +198,9 @@ nng_recv_aio(nng_socket sid, nng_aio *aio)
int rv;
if ((rv = nni_sock_find(&sock, sid)) != 0) {
- nni_aio_finish_error(aio, rv);
+ if (nni_aio_begin(aio) == 0) {
+ nni_aio_finish_error(aio, rv);
+ }
return;
}
nni_sock_recv(sock, aio);
@@ -211,8 +213,16 @@ nng_send_aio(nng_socket sid, nng_aio *aio)
nni_sock *sock;
int rv;
+ if (nni_aio_get_msg(aio) == NULL) {
+ if (nni_aio_begin(aio) == 0) {
+ nni_aio_finish_error(aio, NNG_EINVAL);
+ }
+ return;
+ }
if ((rv = nni_sock_find(&sock, sid)) != 0) {
- nni_aio_finish_error(aio, rv);
+ if (nni_aio_begin(aio) == 0) {
+ nni_aio_finish_error(aio, rv);
+ }
return;
}
nni_sock_send(sock, aio);
@@ -260,7 +270,9 @@ nng_ctx_recv(nng_ctx cid, nng_aio *aio)
nni_ctx *ctx;
if ((rv = nni_ctx_find(&ctx, cid, false)) != 0) {
- nni_aio_finish_error(aio, rv);
+ if (nni_aio_begin(aio) == 0) {
+ nni_aio_finish_error(aio, rv);
+ }
return;
}
nni_ctx_recv(ctx, aio);
@@ -273,8 +285,16 @@ nng_ctx_send(nng_ctx cid, nng_aio *aio)
int rv;
nni_ctx *ctx;
+ if (nni_aio_get_msg(aio) == NULL) {
+ if (nni_aio_begin(aio) == 0) {
+ nni_aio_finish_error(aio, NNG_EINVAL);
+ }
+ return;
+ }
if ((rv = nni_ctx_find(&ctx, cid, false)) != 0) {
- nni_aio_finish_error(aio, rv);
+ if (nni_aio_begin(aio) == 0) {
+ nni_aio_finish_error(aio, rv);
+ }
return;
}
nni_ctx_send(ctx, aio);