aboutsummaryrefslogtreecommitdiff
path: root/src/sp/nonblock_test.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2025-01-01 17:06:39 -0800
committerGarrett D'Amore <garrett@damore.org>2025-01-01 17:06:39 -0800
commitf7bf24f429cbc488b861ab1b1e4cf1983af56295 (patch)
tree2196361a906bd5db1148c0e177d69854a99b7b58 /src/sp/nonblock_test.c
parentee5c8437f8c2a811c0eaef9b00c149b93c095391 (diff)
downloadnng-f7bf24f429cbc488b861ab1b1e4cf1983af56295.tar.gz
nng-f7bf24f429cbc488b861ab1b1e4cf1983af56295.tar.bz2
nng-f7bf24f429cbc488b861ab1b1e4cf1983af56295.zip
api: Remove the NNG_FLAG_ALLOC
This flag failed to provide real zero copy that it was intended for, and it also involved extra allocations. Further, the API for it was brittle and error prone. Modern code should just work directly with nng_msg structures.
Diffstat (limited to 'src/sp/nonblock_test.c')
-rw-r--r--src/sp/nonblock_test.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/sp/nonblock_test.c b/src/sp/nonblock_test.c
index 7b2251c4..c06fa64d 100644
--- a/src/sp/nonblock_test.c
+++ b/src/sp/nonblock_test.c
@@ -1,5 +1,5 @@
//
-// Copyright 2024 Staysail Systems, Inc. <info@staysail.tech>
+// Copyright 2025 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
@@ -46,8 +46,7 @@ repthr(void *arg)
for (;;) {
fd_set fset;
struct timeval tmo;
- char *msgbuf;
- size_t msglen;
+ nng_msg *msg;
FD_ZERO(&fset);
FD_SET(fd, &fset);
@@ -59,14 +58,13 @@ repthr(void *arg)
for (;;) {
int rv;
- rv = nng_recv(rep, &msgbuf, &msglen,
- NNG_FLAG_NONBLOCK | NNG_FLAG_ALLOC);
+ rv = nng_recvmsg(rep, &msg, NNG_FLAG_NONBLOCK);
if (rv != 0) {
return;
}
- nng_free(msgbuf, msglen);
- int ok = 0;
- rv = nng_send(rep, &ok, 4, NNG_FLAG_NONBLOCK);
+ nng_msg_clear(msg);
+ nng_msg_append_u32(msg, 0);
+ rv = nng_sendmsg(rep, msg, NNG_FLAG_NONBLOCK);
if (rv == NNG_ECLOSED) {
return;
}