Page MenuHomeFreeBSD

The socket SO_LINGER option don't work.
AcceptedPublic

Authored by shichun_ma_dell.com on Feb 22 2021, 6:14 AM.
Tags
None
Referenced Files
Unknown Object (File)
Oct 4 2024, 4:57 PM
Unknown Object (File)
Oct 2 2024, 2:16 PM
Unknown Object (File)
Oct 2 2024, 5:44 AM
Unknown Object (File)
Oct 2 2024, 2:12 AM
Unknown Object (File)
Sep 30 2024, 7:04 PM
Unknown Object (File)
Sep 9 2024, 1:06 PM
Unknown Object (File)
Sep 8 2024, 12:51 AM
Unknown Object (File)
Aug 12 2024, 11:21 PM

Details

Reviewers
rscheff
Group Reviewers
transport
network
Summary

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.

Test Plan

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

shichun_ma_dell.com created this revision.
rscheff added a subscriber: rscheff.

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...

This revision is now accepted and ready to land.Mar 9 2021, 5:10 PM

Could you describe what the observed behaviour without this patch is and what the intended behaviour is for a TCP socket?

May you please provide context to the diff?

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.