author | Michael Krelin <hacker@klever.net> | 2008-02-24 16:40:58 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2008-02-24 16:40:58 (UTC) |
commit | f4db51309c0333434d9ee96bc52593dacab04c69 (patch) (unidiff) | |
tree | 07f750cf2bce44a41bb7f785a61695eab73ee529 /src | |
parent | ab29597add2b0ca62a05a274aa90b3ec770a75cc (diff) | |
download | kingate-f4db51309c0333434d9ee96bc52593dacab04c69.zip kingate-f4db51309c0333434d9ee96bc52593dacab04c69.tar.gz kingate-f4db51309c0333434d9ee96bc52593dacab04c69.tar.bz2 |
provide for running as a web server child
that is, if socket being opened is a null pointer, use FCGI_LISTENSOCK_FILENO
Signed-off-by: Michael Krelin <hacker@klever.net>
-rw-r--r-- | src/fastcgi.cc | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/fastcgi.cc b/src/fastcgi.cc index 8b7668c..63b59f8 100644 --- a/src/fastcgi.cc +++ b/src/fastcgi.cc | |||
@@ -1,9 +1,10 @@ | |||
1 | #include <unistd.h> | 1 | #include <unistd.h> |
2 | #include <sys/types.h> | 2 | #include <sys/types.h> |
3 | #include <sys/stat.h> | 3 | #include <sys/stat.h> |
4 | #include <fastcgi.h> | ||
4 | #include "kingate/fastcgi.h" | 5 | #include "kingate/fastcgi.h" |
5 | #include "kingate/exception.h" | 6 | #include "kingate/exception.h" |
6 | 7 | ||
7 | namespace kingate { | 8 | namespace kingate { |
8 | 9 | ||
9 | bool fcgi_socket::_initialized = false; | 10 | bool fcgi_socket::_initialized = false; |
@@ -12,20 +13,24 @@ namespace kingate { | |||
12 | : sock(-1) { | 13 | : sock(-1) { |
13 | if(!_initialized) { | 14 | if(!_initialized) { |
14 | if( FCGX_Init() ) | 15 | if( FCGX_Init() ) |
15 | throw exception(CODEPOINT,"failed to FCGX_Init()"); | 16 | throw exception(CODEPOINT,"failed to FCGX_Init()"); |
16 | _initialized = true; | 17 | _initialized = true; |
17 | } | 18 | } |
19 | if(!s) { | ||
20 | sock = FCGI_LISTENSOCK_FILENO; | ||
21 | }else{ | ||
18 | sock = FCGX_OpenSocket(s,bl); | 22 | sock = FCGX_OpenSocket(s,bl); |
19 | if(sock<0) | 23 | if(sock<0) |
20 | throw exception(CODEPOINT,"failed to FCGX_OpenSocket("); | 24 | throw exception(CODEPOINT,"failed to FCGX_OpenSocket("); |
21 | // TODO: check if there is a ':', not if it starts with ':' | 25 | // TODO: check if there is a ':', not if it starts with ':' |
22 | if(*s != ':') | 26 | if(*s != ':') |
23 | if(chmod(s,0777)) // XXX: configurable. | 27 | if(chmod(s,0777)) // XXX: configurable. |
24 | throw exception(CODEPOINT,"failed to chmod()"); | 28 | throw exception(CODEPOINT,"failed to chmod()"); |
25 | } | 29 | } |
30 | } | ||
26 | fcgi_socket::fcgi_socket(int s) | 31 | fcgi_socket::fcgi_socket(int s) |
27 | : sock(0) { | 32 | : sock(0) { |
28 | if(!_initialized) { | 33 | if(!_initialized) { |
29 | if( FCGX_Init() ) | 34 | if( FCGX_Init() ) |
30 | throw exception(CODEPOINT,"failed to FCGX_Init()"); | 35 | throw exception(CODEPOINT,"failed to FCGX_Init()"); |
31 | _initialized = true; | 36 | _initialized = true; |