Reputation: 270
On a CentOS 7 system, C++ application is having connections hang up in the close_wait state and the daemon stops responding to network traffic. My understanding is that the Kernel handles the TCP stack management and is responsible for reaping these connections.
What could cause these connections to get hung up and what types of bugs should I be looking for in this software? For example, might the application be failing to shut down the socket, or might something else be going on?
Upvotes: 1
Views: 9597
Reputation: 4263
The software running on the end where you see the connections in the CLOSE_WAIT state is not closing the sockets (for example, explicitly calling close()) after receiving FINs from other side.
CLOSE_WAIT state means that the connection is in half-close state, that is, the other end closed its side of the connection but this end did not. This is completely valid in TCP since connections are full-duplex.
In this sequence diagram, server enters the CLOSE_WAIT state after receiving the FIN, and will remain in that state until it calls close.
Upvotes: 3