GNOME Bugzilla – Bug 686213
Half open TCP sockets remain open after soup_session_abort
Last modified: 2012-10-16 14:28:01 UTC
Created attachment 226530 [details] fdleak.c Hi, lsof reports opened file descriptors after `soup_session_abort`. HOW TO REPRODUCE: 1. create async soup session 2. enqueue a request to a service resulting in an long lasting embryonic connection state (http://en.wikipedia.org/wiki/TCP_half-open) example: try to connect to a service behind a firewall. netstat will report SYN_SENT state for this connection. 3. call soup_session_abort after a while EXPECTED OUTCOME: All sockets are closed. lsof shows no FDs of sockets used in session ACTUAL OUTCOME: SYN_SENT state sockets remain open, OS decides it is no longer a tcp connection. lsof shows FDs with "cant't identify protocol" information. ENVIRONMENT: Tested on: - Ubuntu 12.04 - libsoup 2.38.1-1 - Ubuntu 12.10 - libsoup 2.40.0 ADDITIONAL INFORMATION: Attached is a simple application. When I run it like that: $ ./fdleak http://i-will-sent-syn_ack-host/ http://i-wont-sent-syn_ack-host/ it will: 1. create event loop, soup session, two messages. 2. enqueue messages, add a callback printing response headers 3. start event loop (first service will respond promptly, headers will be printed) 4. soup_session_abort will be called in a timeout callback after 3 seconds, after 5 seconds session will be cleaned up and event loop will quit. 5. socket trying to connect to second service will remain in SYN_SENT state. Later it will be reported as lsof as "cant't identify protocol" FD. When a "timeout" property for session is set SYN_SENT sockets are closed after the timeout and everything is fine. I noticed that "disconnected" signal is emited after calling soup_session_abort for appropriate number of soup-connection objects. Maybe the bug is somewhere in `soup_socket_disconnect`. Thanks and Regards, Przemysław Suliga
The bug was in glib, and is now fixed in master and the glib-2-34 branch, but unfortunately not in glib 2.34.1.