Project

General

Profile

Bug #2771

With mod_cgi I am getting sockets disabled, out-of-fds error

Added by asifgoldpk about 1 year ago. Updated about 1 year ago.

Status:
Fixed
Priority:
Normal
Assignee:
-
Category:
mod_cgi
Target version:
Start date:
2016-11-24
Due date:
% Done:

100%

Estimated time:
Missing in 1.5.x:

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.


Related issues

Has duplicate Bug #2775: lighttpd 1.4.42, 1.4.43 hangs during continuous pollingDuplicate2016-12-12

Associated revisions

Revision 99925202 (diff)
Added by gstrauss about 1 year ago

[mod_cgi] fix out of sockets error for POST to CGI (fixes #2771)

(thx asifgoldpk)

x-ref:
"With mod_cgi I am getting sockets disabled, out-of-fds error"
https://redmine.lighttpd.net/issues/2771

History

#1

Updated by gstrauss about 1 year 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));
                        }
#2

Updated by gstrauss about 1 year ago

  • Status changed from Patch Pending to Fixed
  • % Done changed from 0 to 100
#3

Updated by asifgoldpk about 1 year 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;
            }

#4

Updated by gstrauss about 1 year 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.

#5

Updated by gstrauss 12 months ago

  • Has duplicate Bug #2775: lighttpd 1.4.42, 1.4.43 hangs during continuous polling added

Also available in: Atom