nanomsg / nng

nanomsg-next-generation -- light-weight brokerless messaging
https://nng.nanomsg.org
MIT License
3.78k stars 485 forks source link

Sendmsg Thread Blocking #1814

Closed wsxjbupt closed 2 months ago

wsxjbupt commented 5 months ago

Describe the bug Sendmsg Thread Blocking

Expected behavior normal running.

Actual Behavior Use the pair_0 protocol for communication, Occasional Sendmsg Thread Block on function nng_aio_wait,Check the call stack information. Everything is normal, pair0_sock->wmq is full, sendmsg thread block on funciton nng_aio_wait,all nng_task is idle. After receiving the message from the peer end, everything returns to normal.

To Reproduce If possible include actual reproduction test code here. Minimal C test cases are perferred.

Environment Details

Additional context Add any other context about the problem here.

gdamore commented 4 months ago

Pair blocks if there is no receiver. That's by design.

If you want to fail the send instead, use nng_aio_set_timeout() to set a short timeout.

gdamore commented 2 months ago

It also blocks due to backpressure.

If you want a non-blocking (but will lose messages if receiver cannot keep up) pattern, check out PUB/SUB.

gdamore commented 2 months ago

I'm closing this because there isn't a bug.