summaryrefslogtreecommitdiffabout
authorMichael Krelin <hacker@klever.net>2008-02-24 16:40:58 (UTC)
committer Michael Krelin <hacker@klever.net>2008-02-24 16:40:58 (UTC)
commitf4db51309c0333434d9ee96bc52593dacab04c69 (patch) (side-by-side diff)
tree07f750cf2bce44a41bb7f785a61695eab73ee529
parentab29597add2b0ca62a05a274aa90b3ec770a75cc (diff)
downloadkingate-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>
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--src/fastcgi.cc19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/fastcgi.cc b/src/fastcgi.cc
index 8b7668c..63b59f8 100644
--- a/src/fastcgi.cc
+++ b/src/fastcgi.cc
@@ -1,40 +1,45 @@
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include <fastcgi.h>
#include "kingate/fastcgi.h"
#include "kingate/exception.h"
namespace kingate {
bool fcgi_socket::_initialized = false;
fcgi_socket::fcgi_socket(const char *s,int bl)
: sock(-1) {
if(!_initialized) {
if( FCGX_Init() )
throw exception(CODEPOINT,"failed to FCGX_Init()");
_initialized = true;
}
- sock = FCGX_OpenSocket(s,bl);
- if(sock<0)
- throw exception(CODEPOINT,"failed to FCGX_OpenSocket(");
- // TODO: check if there is a ':', not if it starts with ':'
- if(*s != ':')
- if(chmod(s,0777)) // XXX: configurable.
- throw exception(CODEPOINT,"failed to chmod()");
+ if(!s) {
+ sock = FCGI_LISTENSOCK_FILENO;
+ }else{
+ sock = FCGX_OpenSocket(s,bl);
+ if(sock<0)
+ throw exception(CODEPOINT,"failed to FCGX_OpenSocket(");
+ // TODO: check if there is a ':', not if it starts with ':'
+ if(*s != ':')
+ if(chmod(s,0777)) // XXX: configurable.
+ throw exception(CODEPOINT,"failed to chmod()");
+ }
}
fcgi_socket::fcgi_socket(int s)
: sock(0) {
if(!_initialized) {
if( FCGX_Init() )
throw exception(CODEPOINT,"failed to FCGX_Init()");
_initialized = true;
}
}
fcgi_socket::~fcgi_socket() {
if(sock>=0)
close(sock);
}
fcgi_interface::fcgi_interface(fcgi_socket& s,int f)
: sbin(buf_sbin,sizeof(buf_sbin)),