Bug #1575

net.inet.tcp.blackhole and spawn-fcgi

Added by Anonymous over 9 years ago. Updated over 9 years ago.

Target version:
Start date:
Due date:
% Done:


Estimated time:
Missing in 1.5.x:


When setting net.inet.tcp.blackhole > 0 on the FreeBSD, spawn-fcgi hangs trying to accomplish the connect syscall on 94'th line of the spawn-fcgi.c:

if (-1 == connect(fcgi_fd, fcgi_addr, servlen)) {

As I understand, this is a simple check for the port availability which can't be accomplished due to the blackhole option activated. As soon as I deactivate the blackhole option, spawn-fcgi spawns correctly.

I suggest to get rid of this check, because later we call a 'bind' syscall anyway, which also returns error in case if the port is already in use. Why do we do redundant checking ?

Additionally it will also fix the things with the FreeBSD blackhole feature.

Here is a diff for review:

-- tofig

Associated revisions

Revision 0adc0af5 (diff)
Added by stbuehler over 9 years ago

Fix #1575: spawn-fcgi: only try to connect to unix socket (not tcp) before spawning

- we do not need to check for a tcp socket this way as bind will fail if the socket is in use;
this does not apply to unix sockets as they are not bound to a filename but to the file, which
we delete before spawning.

git-svn-id: svn:// 152afb58-edef-0310-8abb-c4023f1b3aa9



Updated by stbuehler over 9 years ago

Did you try what happens if you start spawn-fcgi a second time?

I think it will delete the first socket (unlink in the source), and create a new one - and then you have 2 fcgi processes running, but the first one is unreachable as its socket is deleted (but not closed); check by killing the second one (with all childs) and try connecting to it (e.g. with the original spawn-fcgi). (Tested on my linux box)

Please give feedback how FreeBSD behaves ;-)


Updated by Anonymous over 9 years ago

When I start the second instance of the unpatched spawn-fcgi it gives me:
spawn-fcgi.c.224: socket is already used, can't spawn
and exits.

With the patch applied it gives me:
spawn-fcgi.c.118: bind failed: Address already in use
and exits.

-- tofig


Updated by admin over 9 years ago

You're using IP sockets, while stbuehler is talking about Unix sockets.


Updated by stbuehler over 9 years ago

Oh... hehe. Should have seen the "tcp" in "net.inet.tcp.blackhole", sry.


Updated by stbuehler over 9 years ago

  • Status changed from New to Fixed
  • Resolution set to fixed

Fixed in r2106

Also available in: Atom