svn: /php/php-src/ branches/PHP_5_4/main/output.c branches/PHP_5_4/main/php_output.h trunk/main/output.c trunk/main/php_output.h

From: Date: Wed, 25 Jan 2012 17:22:46 +0000
Subject: svn: /php/php-src/ branches/PHP_5_4/main/output.c branches/PHP_5_4/main/php_output.h trunk/main/output.c trunk/main/php_output.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-67545@lists.php.net to get a copy of this message
mike Wed, 25 Jan 2012 17:22:46 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=322743 Log: fix crash with display_startup_errors=1 Changed paths: U php/php-src/branches/PHP_5_4/main/output.c U php/php-src/branches/PHP_5_4/main/php_output.h U php/php-src/trunk/main/output.c U php/php-src/trunk/main/php_output.h Modified: php/php-src/branches/PHP_5_4/main/output.c =================================================================== --- php/php-src/branches/PHP_5_4/main/output.c 2012-01-25 15:59:08 UTC (rev 322742) +++ php/php-src/branches/PHP_5_4/main/output.c 2012-01-25 17:22:46 UTC (rev 322743) @@ -85,6 +85,18 @@ } /* }}} */ +/* {{{ stderr writer if not PHP_OUTPUT_ACTIVATED */ +static int php_output_stderr(const char *str, size_t str_len) +{ + fwrite(str, 1, str_len, stderr); +/* See http://support.microsoft.com/kb/190351 */ +#ifdef PHP_WIN32 + fflush(stderr); +#endif + return str_len; +} +/* }}} */ + /* {{{ void php_output_startup(void) * Set up module globals and initalize the conflict and reverse conflict hash tables */ PHPAPI void php_output_startup(void) @@ -117,6 +129,7 @@ #endif zend_stack_init(&OG(handlers)); + OG(flags) |= PHP_OUTPUT_ACTIVATED; return SUCCESS; } @@ -139,6 +152,8 @@ } zend_stack_destroy(&OG(handlers)); } + + OG(flags) ^= PHP_OUTPUT_ACTIVATED; } /* }}} */ @@ -174,9 +189,11 @@ * Get output control status */ PHPAPI int php_output_get_status(TSRMLS_D) { - return OG(flags) - | (OG(active) ? PHP_OUTPUT_ACTIVE : 0) - | (OG(running)? PHP_OUTPUT_LOCKED : 0); + return ( + OG(flags) + | (OG(active) ? PHP_OUTPUT_ACTIVE : 0) + | (OG(running)? PHP_OUTPUT_LOCKED : 0) + ) & 0xff; } /* }}} */ @@ -187,7 +204,10 @@ if (OG(flags) & PHP_OUTPUT_DISABLED) { return 0; } - return sapi_module.ub_write(str, len TSRMLS_CC); + if (OG(flags) & PHP_OUTPUT_ACTIVATED) { + return sapi_module.ub_write(str, len TSRMLS_CC); + } + return php_output_stderr(str, len); } /* }}} */ @@ -198,8 +218,11 @@ if (OG(flags) & PHP_OUTPUT_DISABLED) { return 0; } - php_output_op(PHP_OUTPUT_HANDLER_WRITE, str, len TSRMLS_CC); - return (int) len; + if (OG(flags) & PHP_OUTPUT_ACTIVATED) { + php_output_op(PHP_OUTPUT_HANDLER_WRITE, str, len TSRMLS_CC); + return (int) len; + } + return php_output_stderr(str, len); } /* }}} */ Modified: php/php-src/branches/PHP_5_4/main/php_output.h =================================================================== --- php/php-src/branches/PHP_5_4/main/php_output.h 2012-01-25 15:59:08 UTC (rev 322742) +++ php/php-src/branches/PHP_5_4/main/php_output.h 2012-01-25 17:22:46 UTC (rev 322743) @@ -67,6 +67,8 @@ /* supplementary flags for php_output_get_status() */ #define PHP_OUTPUT_ACTIVE 0x10 #define PHP_OUTPUT_LOCKED 0x20 +/* output layer is ready to use */ +#define PHP_OUTPUT_ACTIVATED 0x100000 /* handler hooks */ typedef enum _php_output_handler_hook_t { Modified: php/php-src/trunk/main/output.c =================================================================== --- php/php-src/trunk/main/output.c 2012-01-25 15:59:08 UTC (rev 322742) +++ php/php-src/trunk/main/output.c 2012-01-25 17:22:46 UTC (rev 322743) @@ -85,6 +85,18 @@ } /* }}} */ +/* {{{ stderr writer if not PHP_OUTPUT_ACTIVATED */ +static int php_output_stderr(const char *str, size_t str_len) +{ + fwrite(str, 1, str_len, stderr); +/* See http://support.microsoft.com/kb/190351 */ +#ifdef PHP_WIN32 + fflush(stderr); +#endif + return str_len; +} +/* }}} */ + /* {{{ void php_output_startup(void) * Set up module globals and initalize the conflict and reverse conflict hash tables */ PHPAPI void php_output_startup(void) @@ -117,6 +129,7 @@ #endif zend_stack_init(&OG(handlers)); + OG(flags) |= PHP_OUTPUT_ACTIVATED; return SUCCESS; } @@ -139,6 +152,8 @@ } zend_stack_destroy(&OG(handlers)); } + + OG(flags) ^= PHP_OUTPUT_ACTIVATED; } /* }}} */ @@ -174,9 +189,11 @@ * Get output control status */ PHPAPI int php_output_get_status(TSRMLS_D) { - return OG(flags) - | (OG(active) ? PHP_OUTPUT_ACTIVE : 0) - | (OG(running)? PHP_OUTPUT_LOCKED : 0); + return ( + OG(flags) + | (OG(active) ? PHP_OUTPUT_ACTIVE : 0) + | (OG(running)? PHP_OUTPUT_LOCKED : 0) + ) & 0xff; } /* }}} */ @@ -187,7 +204,10 @@ if (OG(flags) & PHP_OUTPUT_DISABLED) { return 0; } - return sapi_module.ub_write(str, len TSRMLS_CC); + if (OG(flags) & PHP_OUTPUT_ACTIVATED) { + return sapi_module.ub_write(str, len TSRMLS_CC); + } + return php_output_stderr(str, len); } /* }}} */ @@ -198,8 +218,11 @@ if (OG(flags) & PHP_OUTPUT_DISABLED) { return 0; } - php_output_op(PHP_OUTPUT_HANDLER_WRITE, str, len TSRMLS_CC); - return (int) len; + if (OG(flags) & PHP_OUTPUT_ACTIVATED) { + php_output_op(PHP_OUTPUT_HANDLER_WRITE, str, len TSRMLS_CC); + return (int) len; + } + return php_output_stderr(str, len); } /* }}} */ Modified: php/php-src/trunk/main/php_output.h =================================================================== --- php/php-src/trunk/main/php_output.h 2012-01-25 15:59:08 UTC (rev 322742) +++ php/php-src/trunk/main/php_output.h 2012-01-25 17:22:46 UTC (rev 322743) @@ -67,6 +67,8 @@ /* supplementary flags for php_output_get_status() */ #define PHP_OUTPUT_ACTIVE 0x10 #define PHP_OUTPUT_LOCKED 0x20 +/* output layer is ready to use */ +#define PHP_OUTPUT_ACTIVATED 0x100000 /* handler hooks */ typedef enum _php_output_handler_hook_t {

« previous php.cvs (#67545) next »