cvs: php4 /sapi/isapi php4isapi.c

From: Date: Mon, 13 Aug 2001 00:36:16 +0000
Subject: cvs: php4 /sapi/isapi php4isapi.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-6762@lists.php.net to get a copy of this message
zeev Sun Aug 12 20:36:16 2001 EDT Modified files: /php4/sapi/isapi php4isapi.c Log: Reverse patches that slipped in by mistake in a whitespace patch. They require some more work... Index: php4/sapi/isapi/php4isapi.c diff -u php4/sapi/isapi/php4isapi.c:1.80 php4/sapi/isapi/php4isapi.c:1.81 --- php4/sapi/isapi/php4isapi.c:1.80 Sat Aug 11 12:39:05 2001 +++ php4/sapi/isapi/php4isapi.c Sun Aug 12 20:36:16 2001 @@ -36,7 +36,6 @@ #include "ext/standard/info.h" #include "php_variables.h" #include "php_ini.h" -#include "ext/standard/head.h" #ifdef WITH_ZEUS # include "httpext.h" @@ -62,7 +61,7 @@ #define ISAPI_POST_DATA_BUF 1024 static zend_bool bFilterLoaded=0; -static zend_bool bIgnoreCrashes=0; +static zend_bool bTerminateThreadsOnError=0; static char *isapi_special_server_variable_names[] = { "ALL_HTTP", @@ -298,7 +297,7 @@ || zend_startup_module(&php_isapi_module)==FAILURE) { return FAILURE; } else { - bIgnoreCrashes = (zend_bool) INI_INT("isapi.ignore_crashes"); + bTerminateThreadsOnError = (zend_bool) INI_INT("isapi.terminate_threads_on_error"); return SUCCESS; } } @@ -692,28 +691,23 @@ } -#ifdef PHP_WIN32 -static int php_isapi_exception_handler(LPEXCEPTION_POINTERS ep TSRMLS_DC) +static void my_endthread() { - if (ep->ExceptionRecord->ExceptionCode==EXCEPTION_STACK_OVERFLOW) { - return EXCEPTION_EXECUTE_HANDLER; +#ifdef PHP_WIN32 + if (bTerminateThreadsOnError) { + _endthread(); } - if (ep->ExceptionRecord->ExceptionCode==EXCEPTION_ACCESS_VIOLATION) { - char buf[1024]; - - _snprintf(buf, sizeof(buf)-1,"PHP has encountered an Access Violation at %p", ep->ExceptionRecord->ExceptionAddress); - php_isapi_report_exception(buf, strlen(buf) TSRMLS_CC); - } else { - char buf[1024]; +#endif +} - _snprintf(buf, sizeof(buf)-1,"PHP has encountered an Unhandled Exception Code %d at %p", ep->ExceptionRecord->ExceptionCode , ep->ExceptionRecord->ExceptionAddress); - php_isapi_report_exception(buf, strlen(buf) TSRMLS_CC); - } - if (bIgnoreCrashes) { - return EXCEPTION_CONTINUE_SEARCH; - } else { - exit(-1); - } +#ifdef PHP_WIN32 +/* ep is accessible only in the context of the __except expression, + * so we have to call this function to obtain it. + */ +BOOL exceptionhandler(LPEXCEPTION_POINTERS *e, LPEXCEPTION_POINTERS ep) +{ + *e=ep; + return TRUE; } #endif @@ -721,6 +715,9 @@ { zend_file_handle file_handle; zend_bool stack_overflown=0; +#ifdef PHP_ENABLE_SEH + LPEXCEPTION_POINTERS e; +#endif TSRMLS_FETCH(); zend_first_try { @@ -760,9 +757,9 @@ efree(SG(request_info).cookie_data); } #ifdef PHP_ENABLE_SEH - } __except(php_isapi_exception_handler(GetExceptionInformation() TSRMLS_CC)) { - /* we only trap stack overflow exceptions */ - if (_exception_code() == EXCEPTION_STACK_OVERFLOW) { + } __except(exceptionhandler(&e, GetExceptionInformation())) { + char buf[1024]; + if (_exception_code()==EXCEPTION_STACK_OVERFLOW) { LPBYTE lpPage; static SYSTEM_INFO si; static MEMORY_BASIC_INFORMATION mi; @@ -790,18 +787,24 @@ } CG(unclean_shutdown)=1; - php_header(); - sapi_isapi_ub_write("Stack overflow", sizeof("Stack overflow")-1 TSRMLS_CC); + _snprintf(buf, sizeof(buf)-1,"PHP has encountered a Stack overflow"); + php_isapi_report_exception(buf, strlen(buf) TSRMLS_CC); + } else if (_exception_code()==EXCEPTION_ACCESS_VIOLATION) { + _snprintf(buf, sizeof(buf)-1,"PHP has encountered an Access Violation at %p", e->ExceptionRecord->ExceptionAddress); + php_isapi_report_exception(buf, strlen(buf) TSRMLS_CC); + my_endthread(); + } else { + _snprintf(buf, sizeof(buf)-1,"PHP has encountered an Unhandled Exception Code %d at %p", e->ExceptionRecord->ExceptionCode , e->ExceptionRecord->ExceptionAddress); + php_isapi_report_exception(buf, strlen(buf) TSRMLS_CC); + my_endthread(); } #endif } #ifdef PHP_ENABLE_SEH __try { php_request_shutdown(NULL); - } __except(php_isapi_exception_handler(GetExceptionInformation() TSRMLS_CC)) { - /* We should only get to this block in case of a stack overflow, - * which is very unlikely - */ + } __except(EXCEPTION_EXECUTE_HANDLER) { + my_endthread(); } #else php_request_shutdown(NULL);

« previous php.cvs (#6762) next »