Skip to content

Commit

Permalink
* NEW [nmq/quictest] Send with nng_send_aio instead of nng_sendmsg (S…
Browse files Browse the repository at this point in the history
…tack use after return).

Signed-off-by: wanghaemq <wangwei@emqx.io>
  • Loading branch information
wanghaEMQ committed May 9, 2024
1 parent fc8c205 commit b2f88d8
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions nanomq/tests/quic_smoke_test.c
Expand Up @@ -60,7 +60,6 @@ publish_large_msg()
return msg;
}


nng_msg *
subscribe_msg()
{
Expand Down Expand Up @@ -336,14 +335,24 @@ echo_loop(int id, int ver)
assert(rv == 0);

// Start to subscribe
nng_aio *aio_ack;
nng_aio_alloc(&aio_ack, NULL, NULL);
assert(aio_ack != NULL);

nng_msg *submsg = subscribe_msg();
assert(submsg != NULL);
assert(0 == nng_sendmsg(sock, submsg, NNG_FLAG_ALLOC));
nng_aio_set_msg(aio_ack, submsg);
nng_send_aio(sock, aio_ack);
nng_aio_wait(aio_ack);
assert(0 == nng_aio_result(aio_ack));

for (int i=0; i<100; ++i) {
nng_msg *smsg = publish_msg();
assert(smsg != NULL);
assert(0 == nng_sendmsg(sock, smsg, NNG_FLAG_ALLOC));
nng_aio_set_msg(aio_ack, smsg);
nng_send_aio(sock, aio_ack);
nng_aio_wait(aio_ack);
assert(0 == nng_aio_result(aio_ack));

nng_msg *rmsg = NULL;
assert(0 == nng_recvmsg(sock, &rmsg, NNG_FLAG_ALLOC));
Expand Down

0 comments on commit b2f88d8

Please sign in to comment.