diff options
| author | Garrett D'Amore <garrett@damore.org> | 2024-04-14 15:43:59 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2024-04-14 18:52:56 -0700 |
| commit | 82b322a37bcf890275f91b56a9a0347be056be9d (patch) | |
| tree | 42a5f763f963c178b854e9326ef89f0d21582424 /src/sp/protocol/reqrep0/xreq.c | |
| parent | 2b967f48a669f7199c40bc730f800e53d6d4fb72 (diff) | |
| download | nng-82b322a37bcf890275f91b56a9a0347be056be9d.tar.gz nng-82b322a37bcf890275f91b56a9a0347be056be9d.tar.bz2 nng-82b322a37bcf890275f91b56a9a0347be056be9d.zip | |
Log protocol connections rejected by protocol.
Diffstat (limited to 'src/sp/protocol/reqrep0/xreq.c')
| -rw-r--r-- | src/sp/protocol/reqrep0/xreq.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/sp/protocol/reqrep0/xreq.c b/src/sp/protocol/reqrep0/xreq.c index 787c230d..b0ff301b 100644 --- a/src/sp/protocol/reqrep0/xreq.c +++ b/src/sp/protocol/reqrep0/xreq.c @@ -1,5 +1,5 @@ // -// Copyright 2021 Staysail Systems, Inc. <info@staysail.tech> +// Copyright 2024 Staysail Systems, Inc. <info@staysail.tech> // Copyright 2018 Capitar IT Group BV <info@capitar.com> // // This software is supplied under the terms of the MIT License, a @@ -21,14 +21,14 @@ typedef struct xreq0_sock xreq0_sock; // An xreq0_sock is our per-socket protocol private structure. struct xreq0_sock { - nni_msgq * uwq; - nni_msgq * urq; + nni_msgq *uwq; + nni_msgq *urq; nni_atomic_int ttl; }; // A req0_pipe is our per-pipe protocol private structure. struct xreq0_pipe { - nni_pipe * pipe; + nni_pipe *pipe; xreq0_sock *req; nni_aio aio_getq; nni_aio aio_send; @@ -115,6 +115,9 @@ xreq0_pipe_start(void *arg) xreq0_sock *s = p->req; if (nni_pipe_peer(p->pipe) != NNG_REQ0_PEER) { + nng_log_warn("NNG-PEER-MISMATCH", + "Peer protocol mismatch: %d != %d, rejected.", + nni_pipe_peer(p->pipe), NNG_REQ0_PEER); return (NNG_EPROTO); } @@ -193,7 +196,7 @@ xreq0_recv_cb(void *arg) { xreq0_pipe *p = arg; xreq0_sock *sock = p->req; - nni_msg * msg; + nni_msg *msg; bool end; if (nni_aio_result(&p->aio_recv) != 0) { @@ -218,7 +221,7 @@ xreq0_recv_cb(void *arg) body = nni_msg_body(msg); end = ((body[0] & 0x80u) != 0); - if (nng_msg_header_append(msg, body, sizeof (uint32_t)) != 0) { + if (nng_msg_header_append(msg, body, sizeof(uint32_t)) != 0) { // TODO: bump a no-memory stat nni_msg_free(msg); // Closing the pipe may release some memory. @@ -227,7 +230,7 @@ xreq0_recv_cb(void *arg) nni_pipe_close(p->pipe); return; } - nni_msg_trim(msg, sizeof (uint32_t)); + nni_msg_trim(msg, sizeof(uint32_t)); } nni_aio_set_msg(&p->aio_putq, msg); nni_msgq_aio_put(sock->urq, &p->aio_putq); |
