Ruby-fcgi patches

Hello,

I have two patches that fix / enhance the C version of ruby-fcgi. This
message was sent to the maintainer several days ago, but I haven’t
received a response. I’m hoping perhaps he reads this list.

The fix:
fcgi_stream_read() does not free the buff variable, which results in
memory leakage that is most noticeable when handling large file
uploads. Simply doing a:

patch-fcgi-xfree (560 Bytes)

patch-ruby-fcgi2 (2.51 KB)

···

FCGI::each { |request|
until request.in.eof?
request.in.read(1024)
end
}

exposes the problem, as the application grows in size with each new
client POST. Calling GC.start does nothing to decrease the size. The
first patch appears to solve this problem.

The second patch adds a new method FCGI::open_socket(socket_path,
tcp_backlog) which allows the library to be used with the
FastCgiExternalServer option of mod_fastcgi for Apache. FCGI::accept()
and FCGI::each() had to be patched to optionally take this new socket
argument. Example usage would be:

sock = FCGI.open_socket(‘localhost:23443’, 10)

FCGI::each(sock) { |request|

}

Thank you for considering these patches.

Regards,
-Brad Hilton