cvs: php4 /ext/standard output.c php_output.h /main main.c

From: Date: Fri, 20 Jul 2001 13:59:00 +0000
Subject: cvs: php4 /ext/standard output.c php_output.h /main main.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-6279@lists.php.net to get a copy of this message
zeev Fri Jul 20 09:59:00 2001 EDT Modified files: /php4/ext/standard output.c php_output.h /php4/main main.c Log: Avoid getting bailouts on text output during shutdown. Text output is now 'officially' disabled during shutdown (this doesn't change the Apache module behavior, but may change behavior of other server modules, in which it was possible to emit output during shutdown; I think it's a good step towards consistency, though) Index: php4/ext/standard/output.c diff -u php4/ext/standard/output.c:1.63 php4/ext/standard/output.c:1.64 --- php4/ext/standard/output.c:1.63 Wed Jul 11 11:27:37 2001 +++ php4/ext/standard/output.c Fri Jul 20 09:59:00 2001 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: output.c,v 1.63 2001/07/11 15:27:37 thies Exp $ */ +/* $Id: output.c,v 1.64 2001/07/20 13:59:00 zeev Exp $ */ #include "php.h" #include "ext/standard/head.h" @@ -77,8 +77,17 @@ OG(php_body_write) = php_ub_body_write; OG(php_header_write) = sapi_module.ub_write; - OG(nesting_level) = 0; - OG(lock) = 0; + OG(ob_nesting_level) = 0; + OG(ob_lock) = 0; + OG(disable_output) = 0; +} + + +PHPAPI void php_output_set_status(zend_bool status) +{ + OLS_FETCH(); + + OG(disable_output) = !status; } @@ -101,7 +110,11 @@ PHPAPI int php_header_write(const char *str, uint str_length) { OLS_FETCH(); - return OG(php_header_write)(str, str_length); + if (OG(disable_output)) { + return 0; + } else { + return OG(php_header_write)(str, str_length); + } } /* {{{ php_start_ob_buffer @@ -110,7 +123,7 @@ { OLS_FETCH(); - if (OG(lock)) { + if (OG(ob_lock)) { return FAILURE; } if (chunk_size) { @@ -136,7 +149,7 @@ SLS_FETCH(); OLS_FETCH(); - if (OG(nesting_level)==0) { + if (OG(ob_nesting_level)==0) { return; } status = 0; @@ -170,13 +183,13 @@ params[0] = &orig_buffer; params[1] = &z_status; - OG(lock) = 1; + OG(ob_lock) = 1; if (call_user_function_ex(CG(function_table), NULL, OG(active_ob_buffer).output_handler, &alternate_buffer, 2, params, 1, NULL)==SUCCESS) { convert_to_string_ex(&alternate_buffer); final_buffer = alternate_buffer->value.str.val; final_buffer_length = alternate_buffer->value.str.len; } - OG(lock) = 0; + OG(ob_lock) = 0; zval_ptr_dtor(&OG(active_ob_buffer).output_handler); if (orig_buffer->refcount==2) { /* free the zval */ FREE_ZVAL(orig_buffer); @@ -191,7 +204,7 @@ final_buffer_length = OG(active_ob_buffer).text_length; } - if (OG(nesting_level)==1) { /* end buffering */ + if (OG(ob_nesting_level)==1) { /* end buffering */ if (SG(headers_sent) && !SG(request_info).headers_only) { OG(php_body_write) = php_ub_body_write_no_header; } else { @@ -209,17 +222,17 @@ if (OG(active_ob_buffer).internal_output_handler) { to_be_destroyed_handled_output[1] = OG(active_ob_buffer).internal_output_handler_buffer; } - if (OG(nesting_level)>1) { /* restore previous buffer */ + if (OG(ob_nesting_level)>1) { /* restore previous buffer */ php_ob_buffer *ob_buffer_p; zend_stack_top(&OG(ob_buffers), (void **) &ob_buffer_p); OG(active_ob_buffer) = *ob_buffer_p; zend_stack_del_top(&OG(ob_buffers)); - if (OG(nesting_level)==2) { /* destroy the stack */ + if (OG(ob_nesting_level)==2) { /* destroy the stack */ zend_stack_destroy(&OG(ob_buffers)); } } - OG(nesting_level)--; + OG(ob_nesting_level)--; } if (send_buffer) { @@ -253,11 +266,11 @@ OLS_FETCH(); BLS_FETCH(); - while (OG(nesting_level)!=0) { + while (OG(ob_nesting_level)!=0) { php_end_ob_buffer(send_buffer, 0); } - if (send_buffer && BG(use_trans_sid)) { + if (!OG(disable_output) && send_buffer && BG(use_trans_sid)) { session_adapt_flush(OG(php_header_write)); } } @@ -290,7 +303,7 @@ { OLS_FETCH(); - if (OG(nesting_level)==0) { + if (OG(ob_nesting_level)==0) { return; } @@ -326,13 +339,13 @@ { OLS_FETCH(); - if (OG(nesting_level)>0) { - if (OG(nesting_level)==1) { /* initialize stack */ + if (OG(ob_nesting_level)>0) { + if (OG(ob_nesting_level)==1) { /* initialize stack */ zend_stack_init(&OG(ob_buffers)); } zend_stack_push(&OG(ob_buffers), &OG(active_ob_buffer), sizeof(php_ob_buffer)); } - OG(nesting_level)++; + OG(ob_nesting_level)++; OG(active_ob_buffer).block_size = block_size; OG(active_ob_buffer).size = initial_size; OG(active_ob_buffer).buffer = (char *) emalloc(initial_size+1); @@ -401,7 +414,7 @@ { OLS_FETCH(); - if (OG(nesting_level)==0) { + if (OG(ob_nesting_level)==0) { return FAILURE; } ZVAL_STRINGL(p,OG(active_ob_buffer).buffer,OG(active_ob_buffer).text_length,1); @@ -415,7 +428,7 @@ { OLS_FETCH(); - if (OG(nesting_level) == 0) { + if (OG(ob_nesting_level) == 0) { return FAILURE; } ZVAL_LONG(p,OG(active_ob_buffer).text_length); @@ -445,6 +458,9 @@ OLS_FETCH(); BLS_FETCH(); + if (OG(disable_output)) { + return 0; + } if (BG(use_trans_sid)) { session_adapt_uris(str, str_length, &newstr, &new_length); } @@ -549,7 +565,7 @@ } else { OG(php_body_write) = php_ub_body_write; } - OG(nesting_level) = 0; + OG(ob_nesting_level) = 0; php_error(E_ERROR, "Cannot use output buffering in output buffering display handlers"); RETURN_FALSE; } Index: php4/ext/standard/php_output.h diff -u php4/ext/standard/php_output.h:1.26 php4/ext/standard/php_output.h:1.27 --- php4/ext/standard/php_output.h:1.26 Mon Jul 2 14:17:09 2001 +++ php4/ext/standard/php_output.h Fri Jul 20 09:59:00 2001 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_output.h,v 1.26 2001/07/02 18:17:09 zeev Exp $ */ +/* $Id: php_output.h,v 1.27 2001/07/20 13:59:00 zeev Exp $ */ #ifndef PHP_OUTPUT_H #define PHP_OUTPUT_H @@ -27,6 +27,7 @@ PHPAPI void php_output_startup(void); PHPAPI void php_output_activate(void); +PHPAPI void php_output_set_status(zend_bool status); void php_output_register_constants(void); PHPAPI int php_body_write(const char *str, uint str_length); PHPAPI int php_header_write(const char *str, uint str_length); @@ -69,8 +70,9 @@ char *output_start_filename; int output_start_lineno; zend_stack ob_buffers; - int nesting_level; - zend_bool lock; + int ob_nesting_level; + zend_bool ob_lock; + zend_bool disable_output; } php_output_globals; Index: php4/main/main.c diff -u php4/main/main.c:1.380 php4/main/main.c:1.381 --- php4/main/main.c:1.380 Tue Jul 17 12:46:06 2001 +++ php4/main/main.c Fri Jul 20 09:59:00 2001 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: main.c,v 1.380 2001/07/17 16:46:06 rasmus Exp $ */ +/* $Id: main.c,v 1.381 2001/07/20 13:59:00 zeev Exp $ */ /* {{{ includes */ @@ -689,6 +689,8 @@ ELS_FETCH(); SLS_FETCH(); PLS_FETCH(); + + php_output_set_status(0); if (setjmp(EG(bailout))==0) { php_end_ob_buffers((zend_bool)(SG(request_info).headers_only?0:1));

« previous php.cvs (#6279) next »