Browse Source

Add -b backlog option (fixes #2422, patch by aschmitz)

git-svn-id: svn://svn.lighttpd.net/spawn-fcgi/trunk@58 4a9f3682-ca7b-49a8-9a55-ba4640e46f83
master
Stefan Bühler 8 years ago
parent
commit
3046f259cb
  1. 3
      NEWS
  2. 8
      spawn-fcgi.1
  3. 15
      src/spawn-fcgi.c

3
NEWS

@ -5,11 +5,12 @@ NEWS
- 1.6.4 -
* Use octal mode for -M (patch by dfjoerg)
* Add -b backlog option (fixes #2422, patch by aschmitz)
- 1.6.3 - 2009-09-23
* Fix unix socket mode change to work without specifying user/group for socket
* Add some ./run script examples for use with daemontools or runit
* Fix Invalid Argument in chmod if mode=-1 (fixes 2033)
* Fix Invalid Argument in chmod if mode=-1 (fixes #2033)
* Add deprecated and /bin/sh info for -f option; wrap syntax output (fixes #2044)
* Add run script examples in automake dist build

8
spawn-fcgi.1

@ -1,4 +1,4 @@
.TH spawn-fcgi 1 "26 March 2009"
.TH spawn-fcgi 1 "21 November 2012"
.
.SH NAME
.
@ -69,6 +69,12 @@ have a look at
.BR multiwatch(1)
if you want to supervise multiple forks on the same socket.
.TP 8
.B \-b <backlog>
backlog to allow on the socket (default 1024). This is usually limited by the kernel too,
check sysctl net.core.somaxconn (default 128) for linux.
.IP
backlog is the queue of connections that the kernel accepts before the userspace application sees them.
.TP 8
.B \-P <path>
Name of the PID file for spawned processes (ignored in no-fork mode)
.TP 8

15
src/spawn-fcgi.c

@ -79,7 +79,7 @@ static int issetugid() {
#define CONST_STR_LEN(s) s, sizeof(s) - 1
static int bind_socket(const char *addr, unsigned short port, const char *unixsocket, uid_t uid, gid_t gid, int mode) {
static int bind_socket(const char *addr, unsigned short port, const char *unixsocket, uid_t uid, gid_t gid, int mode, int backlog) {
int fcgi_fd, socket_type, val;
struct sockaddr_un fcgi_addr_un;
@ -208,7 +208,7 @@ static int bind_socket(const char *addr, unsigned short port, const char *unixso
}
}
if (-1 == listen(fcgi_fd, 1024)) {
if (-1 == listen(fcgi_fd, backlog)) {
fprintf(stderr, "spawn-fcgi: listen failed: %s\n", strerror(errno));
return -1;
}
@ -427,6 +427,7 @@ static void show_help () {
" -C <children> (PHP only) numbers of childs to spawn (default: not setting\n" \
" the PHP_FCGI_CHILDREN environment variable - PHP defaults to 0)\n" \
" -F <children> number of children to fork (default 1)\n" \
" -b <backlog> backlog to allow on the socket (default 1024)\n" \
" -P <path> name of PID-file for spawned process (ignored in no-fork mode)\n" \
" -n no fork (for daemontools)\n" \
" -v show version\n" \
@ -455,6 +456,7 @@ int main(int argc, char **argv) {
int sockmode = -1;
int child_count = -1;
int fork_count = 1;
int backlog = 1024;
int i_am_root, o;
int pid_fd = -1;
int nofork = 0;
@ -469,7 +471,7 @@ int main(int argc, char **argv) {
i_am_root = (getuid() == 0);
while (-1 != (o = getopt(argc, argv, "c:d:f:g:?hna:p:u:vC:F:s:P:U:G:M:S"))) {
while (-1 != (o = getopt(argc, argv, "c:d:f:g:?hna:p:b:u:vC:F:s:P:U:G:M:S"))) {
switch(o) {
case 'f': fcgi_app = optarg; break;
case 'd': fcgi_dir = optarg; break;
@ -482,6 +484,7 @@ int main(int argc, char **argv) {
break;
case 'C': child_count = strtol(optarg, NULL, 10);/* */ break;
case 'F': fork_count = strtol(optarg, NULL, 10);/* */ break;
case 'b': backlog = strtol(optarg, NULL, 10);/* */ break;
case 's': unixsocket = optarg; /* unix-domain socket */ break;
case 'c': if (i_am_root) { changeroot = optarg; }/* chroot() */ break;
case 'u': if (i_am_root) { username = optarg; } /* set user */ break;
@ -581,7 +584,7 @@ int main(int argc, char **argv) {
if (0 == sockuid) sockuid = uid;
if (0 == sockgid) sockgid = gid;
if (sockbeforechroot && -1 == (fcgi_fd = bind_socket(addr, port, unixsocket, sockuid, sockgid, sockmode)))
if (sockbeforechroot && -1 == (fcgi_fd = bind_socket(addr, port, unixsocket, sockuid, sockgid, sockmode, backlog)))
return -1;
/* Change group before chroot, when we have access
@ -606,7 +609,7 @@ int main(int argc, char **argv) {
}
}
if (!sockbeforechroot && -1 == (fcgi_fd = bind_socket(addr, port, unixsocket, sockuid, sockgid, sockmode)))
if (!sockbeforechroot && -1 == (fcgi_fd = bind_socket(addr, port, unixsocket, sockuid, sockgid, sockmode, backlog)))
return -1;
/* drop root privs */
@ -614,7 +617,7 @@ int main(int argc, char **argv) {
setuid(uid);
}
} else {
if (-1 == (fcgi_fd = bind_socket(addr, port, unixsocket, 0, 0, sockmode)))
if (-1 == (fcgi_fd = bind_socket(addr, port, unixsocket, 0, 0, sockmode, backlog)))
return -1;
}

Loading…
Cancel
Save