Project

General

Profile

Actions

Bug #2771

closed

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

Added by asifgoldpk almost 8 years ago. Updated almost 8 years ago.

Status:
Fixed
Priority:
Normal
Category:
mod_cgi
Target version:
ASK QUESTIONS IN Forums:

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 1 (0 open1 closed)

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

Updated by gstrauss almost 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));
                        }
Actions #2

Updated by gstrauss almost 8 years ago

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

Updated by asifgoldpk almost 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;
            }

Actions #4

Updated by gstrauss almost 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.

Actions #5

Updated by gstrauss almost 8 years ago

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

Also available in: Atom