TCP sockets not cleaned up correctly
|Reported by:||mjw||Owned by:||axeld|
|Component:||Network & Internet/TCP||Version:||R1/pre-alpha1|
|Has a Patch:||no||Platform:||All|
Consider two processes: a server and a client. If the server dies or exits gracefully when there is still data in the server socket's receive queue, then neither the server or client's sockets get cleaned up correctly by the OS.
To reproduce, I have created two example programs, a server and a client. The server waits for a connection, then reads 100 bytes, waits for a second, then exits. The client attaches to the server, sends 100 * 100 bytes, waits 10 seconds, then exits.
After the processes have finished, Running netstat shows that the server's socket has got 9900 bytes in the recv queue, and the socket goes into the time-wait state. The client's socket goes into the closed state with 0 bytes in both the send and recv queues. Running netstat repeatedly for some time shows that the sockets never get cleaned up.
I am not a real TCP expert, but I would imagine that these sockets would disappear from the netstat output after about 2 minutes.
The attached test case includes 2 .c files, and a Jamfile which assumes that the .c files are copied into $HAIKU/src/apps/sock_close_test.
I am running Haiku hrev23220 under qemu.