summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@php.net>2006-03-17 09:32:30 +0000
committerDmitry Stogov <dmitry@php.net>2006-03-17 09:32:30 +0000
commit76a7240d70ae90eb614cb0ecab772309b8798030 (patch)
tree6de83605087ecebecc4a48ba6e93f07b6bcc09c1
parent55159796b09d92e8dd63f41c567fdf17d31c64d1 (diff)
downloadphp-git-76a7240d70ae90eb614cb0ecab772309b8798030.tar.gz
Optimized FastCGI SAPI check. Check for ini options only once.
-rw-r--r--sapi/cgi/cgi_main.c55
1 files changed, 32 insertions, 23 deletions
diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c
index 5cc3d25e86..193506a346 100644
--- a/sapi/cgi/cgi_main.c
+++ b/sapi/cgi/cgi_main.c
@@ -151,6 +151,13 @@ static const opt_struct OPTIONS[] = {
long fix_pathinfo = 1;
#endif
+#if PHP_FASTCGI
+long fcgi_logging = 1;
+#endif
+
+static long rfc2616_headers = 0;
+static long cgi_nph = 0;
+
#ifdef PHP_WIN32
#define TRANSLATE_SLASHES(path) \
{ \
@@ -293,25 +300,12 @@ static int sapi_cgi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC)
char buf[SAPI_CGI_MAX_HEADER_LENGTH];
sapi_header_struct *h;
zend_llist_position pos;
- long rfc2616_headers = 0, nph = 0;
if (SG(request_info).no_headers == 1) {
return SAPI_HEADER_SENT_SUCCESSFULLY;
}
- /* Check wheater to send RFC2616 style headers compatible with
- * PHP versions 4.2.3 and earlier compatible with web servers
- * such as IIS. Default is informal CGI RFC header compatible
- * with Apache.
- */
- if (cfg_get_long("cgi.rfc2616_headers", &rfc2616_headers) == FAILURE) {
- rfc2616_headers = 0;
- }
-
- if (cfg_get_long("cgi.nph", &nph) == FAILURE) {
- nph = 0;
- }
- if (nph || SG(sapi_headers).http_response_code != 200)
+ if (cgi_nph || SG(sapi_headers).http_response_code != 200)
{
int len;
@@ -473,15 +467,11 @@ static void sapi_cgi_register_variables(zval *track_vars_array TSRMLS_DC)
static void sapi_cgi_log_message(char *message)
{
#if PHP_FASTCGI
- long logging = 1;
- TSRMLS_FETCH();
-
- if (cfg_get_long("fastcgi.logging", &logging) == FAILURE) {
- logging = 1;
- }
-
- if (!FCGX_IsCGI() && logging) {
- FCGX_Request *request = (FCGX_Request *) SG(server_context);
+ if (!FCGX_IsCGI() && fcgi_logging) {
+ FCGX_Request *request;
+ TSRMLS_FETCH();
+
+ request = (FCGX_Request *) SG(server_context);
if (request) {
FCGX_FPrintF(request->err, "%s\n", message);
}
@@ -1126,6 +1116,25 @@ consult the installation file that came with this distribution, or visit \n\
#endif
#if PHP_FASTCGI
+ if (cfg_get_long("fastcgi.logging", &fcgi_logging) == FAILURE) {
+ fcgi_logging = 1;
+ }
+#endif
+
+ /* Check wheater to send RFC2616 style headers compatible with
+ * PHP versions 4.2.3 and earlier compatible with web servers
+ * such as IIS. Default is informal CGI RFC header compatible
+ * with Apache.
+ */
+ if (cfg_get_long("cgi.rfc2616_headers", &rfc2616_headers) == FAILURE) {
+ rfc2616_headers = 0;
+ }
+
+ if (cfg_get_long("cgi.nph", &cgi_nph) == FAILURE) {
+ cgi_nph = 0;
+ }
+
+#if PHP_FASTCGI
#ifndef PHP_WIN32
/* for windows, socket listening is broken in the fastcgi library itself
so dissabling this feature on windows till time is available to fix it */