Ticket #1716 (closed defect: fixed)

Opened 7 weeks ago

Last modified 4 weeks ago

mod_scgi process spawning without replacing fd=0 (stdin) by socket as in fcgi

Reported by: artyomtnk@… Owned by: jan
Priority: normal Milestone: 1.4.20
Component: core Version: 1.4.19
Severity: normal Keywords:
Cc: Blocked By:
Need User Feedback: no Blocking:

Description

mod_scgi is quite similar to mod_fastcgi however, it has an important issue:

When scgi process is spawned its stdin fd do not replaced with socket.

Little description: there are two ways to connect to f/scgi process:

1. By predefined socket
2. By opening stdin as an input socket: this method is usually used in most of cases when lighty spwans fastcgi process.

So operations are:

1. Create socket /tmp/somesock
2. Bind to socket
3. Fork a process
4. Close fd=0 and copy our new socket to fd=0 (stdin) by dup2
5. Exec a process when fd=0 is socket and fastcgi process can call accept(2) on this fd (part of standard fastcgi method)

However 4th step is not done in case of scgi which makes facility of spawning of several scgi process by web server quite usless (unless I accidentially guess what is the socket should be opened for lighty)

Attachments

mod_scgi.patch (362 bytes) - added by artyomtnk@… 7 weeks ago.
Patch that fixes the issue

Change History

Changed 7 weeks ago by artyomtnk@…

Patch that fixes the issue

Changed 7 weeks ago by artyomtnk@…

Simple code to reproduce the problem:

Lighttpd configuration:

server.modules              = ("mod_scgi")
server.document-root        = "./"
server.port = 8080
server.bind = "127.0.0.1"

scgi.server = ( "/bb" =>
( "localhost" => (
      "check-local" => "disable",
      "bin-path" => "./a.out",
      "socket" => "/tmp/bb-fastcgi.socket"
)))

VERY Simple C SCGI application:

#include <stdio.h>
#include <unistd.h>
#include <sys/socket.h>
#include <stdlib.h>
#include <string.h>

char buffer[16384];

int main()
{
        for(;;) {
                int s=accept(0,NULL,NULL);
                if(s<0) {
                        perror("accept");
                        exit(1);
                }
                char const msg[]="Content-Type: text/html\r\n\r\n<h1>Hello World</h1>\r\n";

                read(s,buffer,16384);
                write(s,msg,strlen(msg));
                close(s);
        }

}

Before patch application exists with the error.

After, accessing to http://127.0.0.1:8080/bb works fine

Changed 6 weeks ago by anonymous

  • milestone changed from 1.5.0 to 1.4.20

Anybody?

Is there any chance that the issue will be fixed? This bug makes server side scgi process spawning useless.

Changed 4 weeks ago by stbuehler

  • status changed from new to closed
  • resolution set to fixed

Fixed in [2257]

Add/Change #1716 (mod_scgi process spawning without replacing fd=0 (stdin) by socket as in fcgi)

Author



Change Properties
<Author field>
Action
as closed
Next status will be 'reopened'
 
Note: See TracTickets for help on using tickets.