diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-01-06 08:18:50 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-01-06 08:21:09 -0800 |
| commit | a2801adffebb6a3679e41789b38ba925ed32832b (patch) | |
| tree | 8e3a743301fedb04d19d9af3e30f5622b737c337 /src/protocol/reqrep/req.c | |
| parent | 601d7a6ca95678613ca576258314f50a6e5e742c (diff) | |
| download | nng-a2801adffebb6a3679e41789b38ba925ed32832b.tar.gz nng-a2801adffebb6a3679e41789b38ba925ed32832b.tar.bz2 nng-a2801adffebb6a3679e41789b38ba925ed32832b.zip | |
Message API was awkward.
The use of a single function to get both size and length actually
turned out to be awkward to use; better to have separate functions
to get each. While here, disable some of the initialization/fork
checks, because it turns out they aren't needed.
Diffstat (limited to 'src/protocol/reqrep/req.c')
| -rw-r--r-- | src/protocol/reqrep/req.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/src/protocol/reqrep/req.c b/src/protocol/reqrep/req.c index d4098526..037acd1c 100644 --- a/src/protocol/reqrep/req.c +++ b/src/protocol/reqrep/req.c @@ -206,20 +206,17 @@ nni_req_pipe_recv(void *arg) int rv; for (;;) { - size_t len; - char *body; rv = nni_pipe_recv(pipe, &msg); if (rv != 0) { break; } // We yank 4 bytes of body, and move them to the header. - body = nni_msg_body(msg, &len); - if (len < 4) { + if (nni_msg_len(msg) < 4) { // Not enough data, just toss it. nni_msg_free(msg); continue; } - if (nni_msg_append_header(msg, body, 4) != 0) { + if (nni_msg_append_header(msg, nni_msg_body(msg), 4) != 0) { // Should be NNG_ENOMEM nni_msg_free(msg); continue; @@ -375,8 +372,6 @@ static nni_msg * nni_req_recvfilter(void *arg, nni_msg *msg) { nni_req_sock *req = arg; - char *header; - size_t len; nni_mtx_lock(&req->mx); if (req->raw) { @@ -385,8 +380,7 @@ nni_req_recvfilter(void *arg, nni_msg *msg) return (msg); } - header = nni_msg_header(msg, &len); - if (len < 4) { + if (nni_msg_header_len(msg) < 4) { nni_mtx_unlock(&req->mx); nni_msg_free(msg); return (NULL); @@ -398,7 +392,7 @@ nni_req_recvfilter(void *arg, nni_msg *msg) nni_msg_free(msg); return (NULL); } - if (memcmp(header, req->reqid, 4) != 0) { + if (memcmp(nni_msg_header(msg), req->reqid, 4) != 0) { // Wrong request id nni_mtx_unlock(&req->mx); nni_msg_free(msg); |
