Project

General

Profile

Bug #1716

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

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

Status:
Fixed
Priority:
Normal
Assignee:
-
Category:
core
Target version:
Start date:
Due date:
% Done:

0%

Missing in 1.5.x:

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)

-- artyomtnk

mod_scgi.patch View - Patch that fixes the issue -- artyomtnk (362 Bytes) Anonymous, 2008-07-11 15:34

Associated revisions

Revision 60b90dad (diff)
Added by stbuehler over 8 years ago

Use filedescriptor 0 for mod_scgi spawn socket, redirect STDERR to /dev/null (#1716)

git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@2257 152afb58-edef-0310-8abb-c4023f1b3aa9

History

#1 Updated by Anonymous over 8 years ago

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

-- artyomtnk

#2 Updated by Anonymous over 8 years ago

Anybody?

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

#3 Updated by stbuehler over 8 years ago

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

Fixed in r2257

Also available in: Atom