Function sodisconnect is run before SO_LINGER option process, so the socket will be closed immediately after data is sent, which will cause another process cannot communicate with current process before the data is received. Because the two process run asynchronous, and client maybe close before server data is received.
Details
use unix socket to communicate between two program.One program run as server, and another as client.
the sent data size of client is very small, and immediately close after calling send .
in the server process, call getpeername function after accept finished.
expect getpeername doesn't return error and error infomation is: "errorno 107 Socket is not connected".
Diff Detail
- Repository
- rG FreeBSD src repository
- Lint
Lint Skipped - Unit
Tests Skipped
Event Timeline
The diff doesn't appear to be case on HEAD.
Other than this, reads like SO_LINGER could never properly work without this since a memory leak was fixed in 2006...
Could you describe what the observed behaviour without this patch is and what the intended behaviour is for a TCP socket?
This ordering (sodisconnect() followed by the soclose tsleep loop) dates to the original import BSD 4.4 Lite Kernel Sources. I agree with @tuexen's comment above, understanding what happens with TCP is very important.