summaryrefslogtreecommitdiffabout
path: root/src/fastcgi.cc
authorMichael Krelin <hacker@klever.net>2005-07-04 18:08:49 (UTC)
committer Michael Krelin <hacker@klever.net>2005-07-04 18:08:49 (UTC)
commitc8bcbfb951eec5fe14dac0b14f4faaf4a9f9f229 (patch) (unidiff)
tree60d24c0465cd57c839fa46de97cc35e59cc5b535 /src/fastcgi.cc
parent43d47575878e4eaf3c8da84bf609fcd0bde595fb (diff)
downloadkingate-c8bcbfb951eec5fe14dac0b14f4faaf4a9f9f229.zip
kingate-c8bcbfb951eec5fe14dac0b14f4faaf4a9f9f229.tar.gz
kingate-c8bcbfb951eec5fe14dac0b14f4faaf4a9f9f229.tar.bz2
added buffers to fastcgi streambufs. It gains compatibility with normal streambuf manipulations at the cost of performance (according to comments in fcgi devkit). The performance lost should not be disastrous, though.
Diffstat (limited to 'src/fastcgi.cc') (more/less context) (ignore whitespace changes)
-rw-r--r--src/fastcgi.cc5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/fastcgi.cc b/src/fastcgi.cc
index 6285370..8b7668c 100644
--- a/src/fastcgi.cc
+++ b/src/fastcgi.cc
@@ -16,49 +16,52 @@ namespace kingate {
16 _initialized = true; 16 _initialized = true;
17 } 17 }
18 sock = FCGX_OpenSocket(s,bl); 18 sock = FCGX_OpenSocket(s,bl);
19 if(sock<0) 19 if(sock<0)
20 throw exception(CODEPOINT,"failed to FCGX_OpenSocket("); 20 throw exception(CODEPOINT,"failed to FCGX_OpenSocket(");
21 // TODO: check if there is a ':', not if it starts with ':' 21 // TODO: check if there is a ':', not if it starts with ':'
22 if(*s != ':') 22 if(*s != ':')
23 if(chmod(s,0777)) // XXX: configurable. 23 if(chmod(s,0777)) // XXX: configurable.
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 : sbin(buf_sbin,sizeof(buf_sbin)),
41 sbout(buf_sbout,sizeof(buf_sbout)),
42 sberr(buf_sberr,sizeof(buf_sberr)),
43 sin(&sbin), sout(&sbout), serr(&sberr) {
41 if( FCGX_InitRequest(&request,s.sock,f) ) 44 if( FCGX_InitRequest(&request,s.sock,f) )
42 throw exception(CODEPOINT,"failed to FCGX_InitRequest()"); 45 throw exception(CODEPOINT,"failed to FCGX_InitRequest()");
43 if( FCGX_Accept_r(&request) ) 46 if( FCGX_Accept_r(&request) )
44 throw exception(CODEPOINT,"failed to FCGX_Accept_r()"); 47 throw exception(CODEPOINT,"failed to FCGX_Accept_r()");
45 sbin.attach(request.in); 48 sbin.attach(request.in);
46 sbout.attach(request.out); 49 sbout.attach(request.out);
47 sberr.attach(request.err); 50 sberr.attach(request.err);
48 for(char **p = request.envp; *p; p++) { 51 for(char **p = request.envp; *p; p++) {
49 const char *e = strchr(*p,'='); 52 const char *e = strchr(*p,'=');
50 if(!e){ 53 if(!e){
51 // XXX: check if we have it already? 54 // XXX: check if we have it already?
52 metavars[*p] = string(0); 55 metavars[*p] = string(0);
53 }else{ 56 }else{
54 int l = e-*p; e++; 57 int l = e-*p; e++;
55 // XXX: check if we have it already? 58 // XXX: check if we have it already?
56 metavars[string(*p,l)]=e; 59 metavars[string(*p,l)]=e;
57 } 60 }
58 } 61 }
59 } 62 }
60 fcgi_interface::~fcgi_interface() { 63 fcgi_interface::~fcgi_interface() {
61 sout.flush(); 64 sout.flush();
62 serr.flush(); 65 serr.flush();
63 FCGX_Finish_r(&request); 66 FCGX_Finish_r(&request);
64 } 67 }