diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-07-16 13:41:29 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-07-16 13:41:29 -0700 |
| commit | 4a0481a0c3dc8e3509a29c58da0de6db0623f86f (patch) | |
| tree | f0f456c9849141817745a7050b4e94dc68ff265f /src/nng.c | |
| parent | 396d8a243df89680b850626193e0b23567b02585 (diff) | |
| download | nng-4a0481a0c3dc8e3509a29c58da0de6db0623f86f.tar.gz nng-4a0481a0c3dc8e3509a29c58da0de6db0623f86f.tar.bz2 nng-4a0481a0c3dc8e3509a29c58da0de6db0623f86f.zip | |
Fix EAGAIN (timeout thread can run before we finish scheduling!)
Diffstat (limited to 'src/nng.c')
| -rw-r--r-- | src/nng.c | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -160,6 +160,13 @@ nng_recvmsg(nng_socket sid, nng_msg **msgp, int flags) rv = nni_sock_recvmsg(sock, msgp, expire); nni_sock_rele(sock); + + // Possibly massage nonblocking attempt. Note that nonblocking is + // still done asynchronously, and the calling thread loses context. + if ((rv == NNG_ETIMEDOUT) && (expire == NNI_TIME_ZERO)) { + rv = NNG_EAGAIN; + } + return (rv); } @@ -214,6 +221,13 @@ nng_sendmsg(nng_socket sid, nng_msg *msg, int flags) rv = nni_sock_sendmsg(sock, msg, expire); nni_sock_rele(sock); + + // Possibly massage nonblocking attempt. Note that nonblocking is + // still done asynchronously, and the calling thread loses context. + if ((rv == NNG_ETIMEDOUT) && (expire == NNI_TIME_ZERO)) { + rv = NNG_EAGAIN; + } + return (rv); } |
