]> granicus.if.org Git - php/commitdiff
Optimized FastCGI SAPI check. Check for ini options only once.
authorDmitry Stogov <dmitry@php.net>
Fri, 17 Mar 2006 09:32:30 +0000 (09:32 +0000)
committerDmitry Stogov <dmitry@php.net>
Fri, 17 Mar 2006 09:32:30 +0000 (09:32 +0000)
sapi/cgi/cgi_main.c

index 5cc3d25e86cfb133c51357e5b949079751e14776..193506a3466b4933e5b75668ac5a2515212fba4c 100644 (file)
@@ -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);
                }
@@ -1125,6 +1115,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