diff options
author | Jan Kneschke <jan@kneschke.de> | 2006-03-07 12:18:46 +0000 |
---|---|---|
committer | Jan Kneschke <jan@kneschke.de> | 2006-03-07 12:18:46 +0000 |
commit | 52d2264cdae1691b592e07a9d147f17b9e4a7f1e (patch) | |
tree | 1adb2039788f993854f6c916f143bf47eb3f4c9d /src | |
parent | 3a51428599b6006f8c8450df3fe2c51c7b11e61d (diff) | |
download | lighttpd-git-52d2264cdae1691b592e07a9d147f17b9e4a7f1e.tar.gz |
added ability to specify which ip address spawn-fci listens on (fixes #504), patch by agkr@pobox.com
git-svn-id: svn+ssh://svn.lighttpd.net/lighttpd/branches/lighttpd-merge-1.4.x@1029 152afb58-edef-0310-8abb-c4023f1b3aa9
Diffstat (limited to 'src')
-rw-r--r-- | src/spawn-fcgi.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/spawn-fcgi.c b/src/spawn-fcgi.c index 99fc31a2..fd869a2c 100644 --- a/src/spawn-fcgi.c +++ b/src/spawn-fcgi.c @@ -41,7 +41,7 @@ typedef int socklen_t; #endif #ifdef HAVE_SYS_UN_H -int fcgi_spawn_connection(char *appPath, unsigned short port, const char *unixsocket, int child_count, int pid_fd, int nofork) { +int fcgi_spawn_connection(char *appPath, char *addr, unsigned short port, const char *unixsocket, int child_count, int pid_fd, int nofork) { int fcgi_fd; int socket_type, status; struct timeval tv = { 0, 100 * 1000 }; @@ -77,7 +77,11 @@ int fcgi_spawn_connection(char *appPath, unsigned short port, const char *unixso fcgi_addr = (struct sockaddr *) &fcgi_addr_un; } else { fcgi_addr_in.sin_family = AF_INET; - fcgi_addr_in.sin_addr.s_addr = htonl(INADDR_ANY); + if (addr != NULL) { + fcgi_addr_in.sin_addr.s_addr = inet_addr(addr); + } else { + fcgi_addr_in.sin_addr.s_addr = htonl(INADDR_ANY); + } fcgi_addr_in.sin_port = htons(port); servlen = sizeof(fcgi_addr_in); @@ -243,6 +247,7 @@ void show_help () { " - spawns fastcgi processes\n" \ "usage:\n" \ " -f <fcgiapp> filename of the fcgi-application\n" \ +" -a <addr> bind to ip address\n" \ " -p <port> bind to tcp-port\n" \ " -s <path> bind to unix-domain socket\n" \ " -C <childs> (PHP only) numbers of childs to spawn (default 5)\n" \ @@ -261,7 +266,8 @@ void show_help () { int main(int argc, char **argv) { char *fcgi_app = NULL, *changeroot = NULL, *username = NULL, - *groupname = NULL, *unixsocket = NULL, *pid_file = NULL; + *groupname = NULL, *unixsocket = NULL, *pid_file = NULL, + *addr = NULL; unsigned short port = 0; int child_count = 5; int i_am_root, o; @@ -270,9 +276,10 @@ int main(int argc, char **argv) { i_am_root = (getuid() == 0); - while(-1 != (o = getopt(argc, argv, "c:f:g:hnp:u:vC:s:P:"))) { + while(-1 != (o = getopt(argc, argv, "c:f:g:hna:p:u:vC:s:P:"))) { switch(o) { case 'f': fcgi_app = optarg; break; + case 'a': addr = optarg;/* ip addr */ break; case 'p': port = strtol(optarg, NULL, 10);/* port */ break; case 'C': child_count = strtol(optarg, NULL, 10);/* */ break; case 's': unixsocket = optarg; /* unix-domain socket */ break; @@ -422,7 +429,7 @@ int main(int argc, char **argv) { if (username) setuid(pwd->pw_uid); } - return fcgi_spawn_connection(fcgi_app, port, unixsocket, child_count, pid_fd, nofork); + return fcgi_spawn_connection(fcgi_app, addr, port, unixsocket, child_count, pid_fd, nofork); } #else int main() { |