Bug #2771
closedWith mod_cgi I am getting sockets disabled, out-of-fds error
Description
2016-11-24 09:52:03: (../../Source/lighttpd-1.4.43/src/server.c.1759) [note] sockets disabled, out-of-fds
It looks like sometimes to_cgi_fds1 gets closed using close() call and sometimes fdevent_sched_close(srv->ev, hctx->fdtocgi, 0). With close() srv->cur_fds does not gets decremented and lighty hangs after some time.
Get requests work the problem is only when posting data to a mod_cgi script.
Updated by gstrauss about 8 years ago
- Status changed from New to Patch Pending
- Target version changed from 1.4.x to 1.4.44
Thanks for tracking that down. Does this patch fix this issue for you?
--- a/src/mod_cgi.c +++ b/src/mod_cgi.c @@ -1027,6 +1027,7 @@ static int cgi_write_request(server *srv, handler_ctx *hctx, int fd) { /* sent all request body input */ /* close connection to the cgi-script */ if (-1 == hctx->fdtocgi) { /*(received request body sent in initial send to pipe buffer)*/ + --srv->cur_fds; if (close(fd)) { log_error_write(srv, __FILE__, __LINE__, "sds", "cgi stdin close failed ", fd, strerror(errno)); }
Updated by gstrauss about 8 years ago
- Status changed from Patch Pending to Fixed
- % Done changed from 0 to 100
Applied in changeset 99925202ddd22cdbe61d654dbe151e2bae6d20d8.
Updated by asifgoldpk about 8 years ago
Seems like working but too many conditional branches make it difficult to understand that it will have covered all the cases.
What do you think about a fix like this?
if (0 != cgi_write_request(srv, hctx, to_cgi_fds[1])) { close(to_cgi_fds[1]); cgi_connection_close(srv, hctx); return -1; } /* new code in cgi_create_env()*/ if (hctx->fdtocgi == to_cgi_fds[1]) { ++srv->cur_fds; }
Updated by gstrauss about 8 years ago
Your suggestion looks like it would probably work, too. However, I prefer to increment srv->cur_fds near where the fds are created, and to decrement srv->cur_fds near where the fds are closed.
Updated by gstrauss almost 8 years ago
- Has duplicate Bug #2775: lighttpd 1.4.42, 1.4.43 hangs during continuous polling added
Also available in: Atom