From b349df63645e48eade0481238e6ca3feb90f18fa Mon Sep 17 00:00:00 2001 From: Sascha Schumann Date: Sun, 5 Aug 2001 16:21:33 +0000 Subject: [PATCH] some more eliminate-fetches-or-escalate-them-at-least --- ext/cpdf/cpdf.c | 2 +- ext/gd/gd.c | 2 +- ext/gd/gd_ctx.c | 6 ++++-- ext/ming/ming.c | 4 +++- ext/pdf/pdf.c | 5 +++-- ext/pgsql/pgsql.c | 2 +- ext/standard/basic_functions.c | 2 +- ext/swf/swf.c | 2 +- ext/zlib/zlib.c | 2 +- main/main.c | 15 ++++++--------- main/php.h | 4 ++-- main/php_main.h | 2 +- sapi/cgi/cgi_main.c | 10 +++++----- sapi/servlet/servlet.c | 6 ++++-- 14 files changed, 34 insertions(+), 30 deletions(-) diff --git a/ext/cpdf/cpdf.c b/ext/cpdf/cpdf.c index bb1ce59fca..3543f72c0f 100644 --- a/ext/cpdf/cpdf.c +++ b/ext/cpdf/cpdf.c @@ -2335,7 +2335,7 @@ PHP_FUNCTION(cpdf_output_buffer) buffer = cpdf_getBufferForPDF(pdf, &lenght); - php_write(buffer, lenght); + php_write(buffer, lenght TSRMLS_CC); RETURN_TRUE; } diff --git a/ext/gd/gd.c b/ext/gd/gd.c index eafac5858d..c60dafbd61 100644 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@ -1382,7 +1382,7 @@ static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, char ap_bsetflag(php3_rqst->connection->client, B_EBCDIC2ASCII, 0); #endif while ((b = fread(buf, 1, sizeof(buf), tmp)) > 0) { - php_write(buf, b); + php_write(buf, b TSRMLS_CC); } fclose(tmp); diff --git a/ext/gd/gd_ctx.c b/ext/gd/gd_ctx.c index 3c389a38ba..3c599cab65 100644 --- a/ext/gd/gd_ctx.c +++ b/ext/gd/gd_ctx.c @@ -5,12 +5,14 @@ static void _php_image_output_putc(struct gdIOCtx *ctx, int c) { - php_write(&c, 1); + TSRMLS_FETCH(); + php_write(&c, 1 TSRMLS_CC); } static int _php_image_output_putbuf(struct gdIOCtx *ctx, const void* buf, int l) { - return php_write((void *)buf, l); + TSRMLS_FETCH(); + return php_write((void *)buf, l TSRMLS_CC); } static void _php_image_output_ctxfree(struct gdIOCtx *ctx) diff --git a/ext/ming/ming.c b/ext/ming/ming.c index 60a3ff8050..46aec90a0f 100644 --- a/ext/ming/ming.c +++ b/ext/ming/ming.c @@ -1489,7 +1489,9 @@ PHP_FUNCTION(swfmovie_remove) void phpByteOutputMethod(byte b, void *data) { - php_write(&b, 1); + TSRMLS_FETCH(); + + php_write(&b, 1 TSRMLS_CC); } PHP_FUNCTION(swfmovie_output) diff --git a/ext/pdf/pdf.c b/ext/pdf/pdf.c index 7274b0e15a..dfb17b328c 100644 --- a/ext/pdf/pdf.c +++ b/ext/pdf/pdf.c @@ -325,8 +325,9 @@ static void pdf_efree(PDF *p, void *mem) */ static size_t pdf_flushwrite(PDF *p, void *data, size_t size) { - return(php_write(data, size)); - return 0; + TSRMLS_FETCH(); + + return(php_write(data, size TSRMLS_CC)); } /* }}} */ diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index 1061ef8583..81fef71dcf 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -174,7 +174,7 @@ _notice_handler(void *arg, const char *message) TSRMLS_FETCH(); if (! PGG(ignore_notices)) { - php_log_err((char *) message); + php_log_err((char *) message TSRMLS_CC); if (PGG(last_notice) != NULL) { efree(PGG(last_notice)); } diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 6370c5e4b2..cc19b0dfaa 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -1614,7 +1614,7 @@ PHPAPI int _php_error_log(int opt_err, char *message, char *opt, char *headers T fclose(logfile); break; default: - php_log_err(message); + php_log_err(message TSRMLS_CC); break; } return SUCCESS; diff --git a/ext/swf/swf.c b/ext/swf/swf.c index b06eba7fd6..3b0ca328b7 100644 --- a/ext/swf/swf.c +++ b/ext/swf/swf.c @@ -255,7 +255,7 @@ PHP_FUNCTION(swf_closefile) } while ((b = fread(buf, 1, sizeof(buf), f)) > 0) - php_write(buf, b); + php_write(buf, b TSRMLS_CC); fclose(f); diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c index a0137878d5..3b5c7ed0ba 100644 --- a/ext/zlib/zlib.c +++ b/ext/zlib/zlib.c @@ -67,7 +67,7 @@ #define PUTC(a) PUTS(a) #endif #ifndef PHPWRITE -#define PHPWRITE(a,n) php_write((a),(n)) +#define PHPWRITE(a,n) php_write((a),(n) TSRMLS_CC) #endif #endif diff --git a/main/main.c b/main/main.c index fc11bad4b2..9562470cef 100644 --- a/main/main.c +++ b/main/main.c @@ -263,13 +263,12 @@ static int module_initialized = 0; /* {{{ php_log_err */ -PHPAPI void php_log_err(char *log_message) +PHPAPI void php_log_err(char *log_message TSRMLS_DC) { FILE *log_file; char error_time_str[128]; struct tm tmbuf; time_t error_time; - TSRMLS_FETCH(); /* Try to use the specified logging location. */ if (PG(error_log) != NULL) { @@ -304,9 +303,8 @@ PHPAPI void php_log_err(char *log_message) /* {{{ php_write wrapper for modules to use PHPWRITE */ -PHPAPI int php_write(void *buf, uint size) +PHPAPI int php_write(void *buf, uint size TSRMLS_DC) { - TSRMLS_FETCH(); return PHPWRITE(buf, size); } /* }}} */ @@ -388,7 +386,7 @@ static void php_error_cb(int type, const char *error_filename, const uint error_ } #endif snprintf(log_buffer, 1024, "PHP %s: %s in %s on line %d", error_type_str, buffer, error_filename, error_lineno); - php_log_err(log_buffer); + php_log_err(log_buffer TSRMLS_CC); } if (module_initialized && PG(display_errors) && (!PG(during_request_startup) || PG(display_startup_errors))) { @@ -553,7 +551,6 @@ static void php_message_handler_for_zend(long message, void *data) if (EG(error_reporting)&E_WARNING) { #if ZEND_DEBUG char memory_leak_buf[512]; - TSRMLS_FETCH(); if (message==ZMSG_MEMORY_LEAK_DETECTED) { zend_mem_header *t = (zend_mem_header *) data; @@ -931,17 +928,17 @@ void php_module_shutdown_for_exec() */ int php_module_shutdown_wrapper(sapi_module_struct *sapi_globals) { - php_module_shutdown(); + TSRMLS_FETCH(); + php_module_shutdown(TSRMLS_C); return SUCCESS; } /* }}} */ /* {{{ php_module_shutdown */ -void php_module_shutdown() +void php_module_shutdown(TSRMLS_D) { int module_number=0; /* for UNREGISTER_INI_ENTRIES() */ - TSRMLS_FETCH(); if (!module_initialized) { return; diff --git a/main/php.h b/main/php.h index d7f6c13f30..fb2f62f666 100644 --- a/main/php.h +++ b/main/php.h @@ -245,9 +245,9 @@ ssize_t pread(int, void *, size_t, off64_t); #endif void phperror(char *error); -PHPAPI int php_write(void *buf, uint size); +PHPAPI int php_write(void *buf, uint size TSRMLS_DC); PHPAPI int php_printf(const char *format, ...); -PHPAPI void php_log_err(char *log_message); +PHPAPI void php_log_err(char *log_message TSRMLS_DC); int Debug(char *format, ...); int cfgparse(void); diff --git a/main/php_main.h b/main/php_main.h index 304d199ff8..9595df11db 100644 --- a/main/php_main.h +++ b/main/php_main.h @@ -32,7 +32,7 @@ PHPAPI int php_request_startup(TSRMLS_D); PHPAPI void php_request_shutdown(void *dummy); PHPAPI void php_request_shutdown_for_exec(void *dummy); PHPAPI int php_module_startup(sapi_module_struct *sf); -PHPAPI void php_module_shutdown(void); +PHPAPI void php_module_shutdown(TSRMLS_D); PHPAPI void php_module_shutdown_for_exec(void); PHPAPI int php_module_shutdown_wrapper(sapi_module_struct *sapi_globals); diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c index 5e09d5a694..2ab43d3239 100644 --- a/sapi/cgi/cgi_main.c +++ b/sapi/cgi/cgi_main.c @@ -563,7 +563,7 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine case 'i': /* php info & quit */ if (php_request_startup(TSRMLS_C)==FAILURE) { - php_module_shutdown(); + php_module_shutdown(TSRMLS_C); return FAILURE; } if (no_headers) { @@ -611,7 +611,7 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine case 'v': /* show php version & quit */ no_headers = 1; if (php_request_startup(TSRMLS_C)==FAILURE) { - php_module_shutdown(); + php_module_shutdown(TSRMLS_C); return FAILURE; } if (no_headers) { @@ -668,7 +668,7 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine } if (php_request_startup(TSRMLS_C)==FAILURE) { - php_module_shutdown(); + php_module_shutdown(TSRMLS_C); return FAILURE; } if (no_headers) { @@ -714,7 +714,7 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine if(!argv0 || !(file_handle.handle.fp = VCWD_FOPEN(argv0, "rb"))) { PUTS("No input file specified.\n"); php_request_shutdown((void *) 0); - php_module_shutdown(); + php_module_shutdown(TSRMLS_C); return FAILURE; } file_handle.filename = argv0; @@ -782,7 +782,7 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine exit_status = -1; } zend_end_try(); - php_module_shutdown(); + php_module_shutdown(TSRMLS_C); #ifdef ZTS tsrm_shutdown(); diff --git a/sapi/servlet/servlet.c b/sapi/servlet/servlet.c index aaf4589b3f..1cb890bae3 100644 --- a/sapi/servlet/servlet.c +++ b/sapi/servlet/servlet.c @@ -269,7 +269,9 @@ JNIEXPORT void JNICALL Java_net_php_servlet_startup JNIEXPORT void JNICALL Java_net_php_servlet_shutdown (JNIEnv *jenv, jobject self) { - php_module_shutdown(); + TSRMLS_FETCH(); + + php_module_shutdown(TSRMLS_C); #ifdef ZTS tsrm_shutdown(); #endif @@ -361,7 +363,7 @@ JNIEXPORT void JNICALL Java_net_php_servlet_send if (retval == FAILURE) { php_request_shutdown((void *) 0); - php_module_shutdown(); + php_module_shutdown(TSRMLS_C); ThrowIOException(jenv, file_handle.filename); return; } -- 2.40.0