Bug #36599
openmsg/async: should read data out of socket after shutdown(), before close()
0%
Description
From a user:
These are right steps to close a TCP session and avoid resets; RESETs are bad and generally should occur only when you kernel queue overflows. (this field is default off, but if we turn it on - then it will indicate that user space process is not able to handle the load; see this field: /proc/sys/net/ipv4/tcp_abort_on_overflow).
1) shutdown(SHUT_WR) - https://linux.die.net/man/3/shutdown
2) Run a readloop and dump what is in socket => Resulting in proper ACK's being sent back to the sender waiting for ACK;
3) When you get read() error on the loop, then issue a full close or do shutdown(SHUT_RD) and you can exit.
This will create a proper FIN-ACK-FIN-ACK sequence and will not result in RESET's between hosts.
We are already doing the shutdown call, but we do not read off any data on the socket before closing.