-rw-r--r-- | src/fastcgi.cc | 1 |
1 files changed, 0 insertions, 1 deletions
diff --git a/src/fastcgi.cc b/src/fastcgi.cc index 7484449..6285370 100644 --- a/src/fastcgi.cc +++ b/src/fastcgi.cc | |||
@@ -24,44 +24,43 @@ namespace kingate { | |||
24 | throw exception(CODEPOINT,"failed to chmod()"); | 24 | throw exception(CODEPOINT,"failed to chmod()"); |
25 | } | 25 | } |
26 | fcgi_socket::fcgi_socket(int s) | 26 | fcgi_socket::fcgi_socket(int s) |
27 | : sock(0) { | 27 | : sock(0) { |
28 | if(!_initialized) { | 28 | if(!_initialized) { |
29 | if( FCGX_Init() ) | 29 | if( FCGX_Init() ) |
30 | throw exception(CODEPOINT,"failed to FCGX_Init()"); | 30 | throw exception(CODEPOINT,"failed to FCGX_Init()"); |
31 | _initialized = true; | 31 | _initialized = true; |
32 | } | 32 | } |
33 | } | 33 | } |
34 | fcgi_socket::~fcgi_socket() { | 34 | fcgi_socket::~fcgi_socket() { |
35 | if(sock>=0) | 35 | if(sock>=0) |
36 | close(sock); | 36 | close(sock); |
37 | } | 37 | } |
38 | 38 | ||
39 | fcgi_interface::fcgi_interface(fcgi_socket& s,int f) | 39 | fcgi_interface::fcgi_interface(fcgi_socket& s,int f) |
40 | : sin(&sbin), sout(&sbout), serr(&sberr) { | 40 | : sin(&sbin), sout(&sbout), serr(&sberr) { |
41 | if( FCGX_InitRequest(&request,s.sock,f) ) | 41 | if( FCGX_InitRequest(&request,s.sock,f) ) |
42 | throw exception(CODEPOINT,"failed to FCGX_InitRequest()"); | 42 | throw exception(CODEPOINT,"failed to FCGX_InitRequest()"); |
43 | if( FCGX_Accept_r(&request) ) | 43 | if( FCGX_Accept_r(&request) ) |
44 | throw exception(CODEPOINT,"failed to FCGX_Accept_r()"); | 44 | throw exception(CODEPOINT,"failed to FCGX_Accept_r()"); |
45 | sbin.attach(request.in); | 45 | sbin.attach(request.in); |
46 | sbout.attach(request.out); | 46 | sbout.attach(request.out); |
47 | sberr.attach(request.err); | 47 | sberr.attach(request.err); |
48 | metavars.clear(); // XXX: redundant. | ||
49 | for(char **p = request.envp; *p; p++) { | 48 | for(char **p = request.envp; *p; p++) { |
50 | const char *e = strchr(*p,'='); | 49 | const char *e = strchr(*p,'='); |
51 | if(!e){ | 50 | if(!e){ |
52 | // XXX: check if we have it already? | 51 | // XXX: check if we have it already? |
53 | metavars[*p] = string(0); | 52 | metavars[*p] = string(0); |
54 | }else{ | 53 | }else{ |
55 | int l = e-*p; e++; | 54 | int l = e-*p; e++; |
56 | // XXX: check if we have it already? | 55 | // XXX: check if we have it already? |
57 | metavars[string(*p,l)]=e; | 56 | metavars[string(*p,l)]=e; |
58 | } | 57 | } |
59 | } | 58 | } |
60 | } | 59 | } |
61 | fcgi_interface::~fcgi_interface() { | 60 | fcgi_interface::~fcgi_interface() { |
62 | sout.flush(); | 61 | sout.flush(); |
63 | serr.flush(); | 62 | serr.flush(); |
64 | FCGX_Finish_r(&request); | 63 | FCGX_Finish_r(&request); |
65 | } | 64 | } |
66 | 65 | ||
67 | } | 66 | } |