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 (show other bugs)
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)

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


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.

Note You need to log in before you can comment on or make changes to this bug.