Bug 3765 - Connections leaking in Mono.Webserver.FastCgi
Summary: Connections leaking in Mono.Webserver.FastCgi
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Web ()
Version: master
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2012-03-06 08:04 UTC by Guillaume Pitel
Modified: 2012-03-14 16:20 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Guillaume Pitel 2012-03-06 08:04:20 UTC
My setup : haproxy loadbalancing on several nginx locally with fastcgi backend connected with unix domain socket to several fastcgi-mono-server4.  

haproxy (80) -> nginx (8080,8081,...) => /tmp/socket1, /tmp/socket2, ...

The problem is that fastcgi-mono-server4 fails to close the sockets it has accepted in some occasions (maybe 1 connection every 200), eventually leading to file descriptor exhaustion.

The problem seems to happen only with haproxy probes (simply doing a loop of wget does not seem to trigger the bug), I don't know why, though. 

The bug is located in method EndRequest in XSP/src/Mono.WebServer.FastCgi/Connection.cs

This code : 

if (IsConnected)
    new Record (1, RecordType.EndRequest, requestID,
         body.GetData ()).Send (socket);

can throw an Exception if the socket is shut down on the client side, however the exception is silently caught and ignored at some upper level, thus preventing the request to be removed from the requests list, and preventing the socket to be properly closed.

I don't know if the bug occurs when using tcp sockets
Comment 1 Gonzalo Paniagua Javier 2012-03-14 16:20:38 UTC
Your fix has been merged in master.