作者:刘胜良昭桂家贤 | 来源:互联网 | 2023-07-08 19:20
Shutting down a socket immediately after binding it or connecting it leads to a state assertion violation. Here's a minimal example
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| c
#include
#include
#include
int main () {
int sock = nn_socket(AF_SP, NN_REQ);
int ep = nn_bind(sock, "inproc://foo");
int res = nn_shutdown(sock, ep);
return 0;
}
|
Compiling this is fine, but at runtime it fails like
1
| Assertion failed: 0 (src/core/sock.c:842) |
.
This can be replicated for all the scalability protocols and for binding and connecting. It doesn't appear to happen for TCP or IPC, however.
If shutdown behaves differently for Inproc then perhaps I missed it in the documentation. I'd think it should behave the same as TCP/IPC, though, or at least be a nop instead of a system failure.
该提问来源于开源项目:nanomsg/nanomsg
Thanks!