mirror of
https://github.com/php/php-src.git
synced 2025-01-25 21:23:45 +08:00
Make MEMORY_LIMIT and ZEND_USE_MALLOC_MM to be always enabled. They don't make a
ny significant slowdown, but incrise maintainability a lot. Note that the setting of memory_limit wasn't changes (neither in main/main.c nor in php.ini) and it still set to 16M.
This commit is contained in:
parent
460360ae53
commit
a7c536fbcd
23
Zend/Zend.m4
23
Zend/Zend.m4
@ -129,13 +129,6 @@ AC_ARG_WITH(zend-vm,
|
||||
PHP_ZEND_VM=CALL
|
||||
])
|
||||
|
||||
AC_ARG_ENABLE(malloc-mm,
|
||||
[ --enable-malloc-mm Use environment variable for run-time malloc/emalloc
|
||||
selection - FOR DEVELOPERS ONLY!!],
|
||||
[
|
||||
ZEND_USE_MALLOC_MM=$enableval
|
||||
])
|
||||
|
||||
AC_ARG_ENABLE(maintainer-zts,
|
||||
[ --enable-maintainer-zts Enable thread safety - for code maintainers only!!],[
|
||||
ZEND_MAINTAINER_ZTS=$enableval
|
||||
@ -151,13 +144,6 @@ AC_ARG_ENABLE(inline-optimization,
|
||||
ZEND_INLINE_OPTIMIZATION=yes
|
||||
])
|
||||
|
||||
AC_ARG_ENABLE(memory-limit,
|
||||
[ --enable-memory-limit Compile with memory limit support], [
|
||||
ZEND_MEMORY_LIMIT=$enableval
|
||||
],[
|
||||
ZEND_MEMORY_LIMIT=no
|
||||
])
|
||||
|
||||
AC_MSG_CHECKING([virtual machine dispatch method])
|
||||
AC_MSG_RESULT($PHP_ZEND_VM)
|
||||
|
||||
@ -167,9 +153,6 @@ AC_MSG_RESULT($ZEND_MAINTAINER_ZTS)
|
||||
AC_MSG_CHECKING(whether to enable inline optimization for GCC)
|
||||
AC_MSG_RESULT($ZEND_INLINE_OPTIMIZATION)
|
||||
|
||||
AC_MSG_CHECKING(whether to enable a memory limit)
|
||||
AC_MSG_RESULT($ZEND_MEMORY_LIMIT)
|
||||
|
||||
AC_MSG_CHECKING(whether to enable Zend debugging)
|
||||
AC_MSG_RESULT($ZEND_DEBUG)
|
||||
|
||||
@ -207,12 +190,6 @@ if test "$ZEND_MAINTAINER_ZTS" = "yes"; then
|
||||
LIBZEND_CPLUSPLUS_CHECKS
|
||||
fi
|
||||
|
||||
if test "$ZEND_MEMORY_LIMIT" = "yes"; then
|
||||
AC_DEFINE(MEMORY_LIMIT, 1, [Memory limit])
|
||||
else
|
||||
AC_DEFINE(MEMORY_LIMIT, 0, [Memory limit])
|
||||
fi
|
||||
|
||||
changequote({,})
|
||||
if test -n "$GCC" && test "$ZEND_INLINE_OPTIMIZATION" != "yes"; then
|
||||
INLINE_CFLAGS=`echo $ac_n "$CFLAGS $ac_c" | sed s/-O[0-9s]*//`
|
||||
|
@ -38,11 +38,6 @@
|
||||
# include <process.h>
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef ZEND_USE_MALLOC_MM
|
||||
# define ZEND_USE_MALLOC_MM ZEND_DEBUG
|
||||
#endif
|
||||
|
||||
#ifndef ZEND_MM_HEAP_PROTECTION
|
||||
# define ZEND_MM_HEAP_PROTECTION ZEND_DEBUG
|
||||
#endif
|
||||
@ -372,16 +367,12 @@ struct _zend_mm_heap {
|
||||
zend_mm_segment *segments_list;
|
||||
zend_mm_storage *storage;
|
||||
size_t real_size;
|
||||
#if MEMORY_LIMIT
|
||||
size_t real_peak;
|
||||
size_t limit;
|
||||
size_t size;
|
||||
size_t peak;
|
||||
void *reserve;
|
||||
#endif
|
||||
#if ZEND_USE_MALLOC_MM
|
||||
int use_zend_alloc;
|
||||
#endif
|
||||
int overflow;
|
||||
#if ZEND_MM_CACHE
|
||||
unsigned int cached;
|
||||
@ -819,21 +810,15 @@ ZEND_API zend_mm_heap *zend_mm_startup_ex(const zend_mm_mem_handlers *handlers,
|
||||
heap->segments_list = NULL;
|
||||
zend_mm_init(heap);
|
||||
|
||||
#if ZEND_USE_MALLOC_MM
|
||||
heap->use_zend_alloc = 1;
|
||||
#endif
|
||||
|
||||
heap->real_size = 0;
|
||||
heap->overflow = 0;
|
||||
|
||||
#if MEMORY_LIMIT
|
||||
heap->real_peak = 0;
|
||||
heap->limit = 1<<30;
|
||||
heap->size = 0;
|
||||
heap->peak = 0;
|
||||
heap->reserve = NULL;
|
||||
heap->reserve = zend_mm_alloc(heap, ZEND_MM_RESERVE_SIZE);
|
||||
#endif
|
||||
|
||||
return heap;
|
||||
}
|
||||
@ -1246,12 +1231,10 @@ ZEND_API void zend_mm_shutdown(zend_mm_heap *heap, int full_shutdown, int silent
|
||||
zend_mm_segment *segment;
|
||||
zend_mm_segment *prev;
|
||||
|
||||
#if MEMORY_LIMIT
|
||||
if (heap->reserve) {
|
||||
zend_mm_free(heap, heap->reserve);
|
||||
heap->reserve = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ZEND_DEBUG
|
||||
if (!silent) {
|
||||
@ -1272,12 +1255,10 @@ ZEND_API void zend_mm_shutdown(zend_mm_heap *heap, int full_shutdown, int silent
|
||||
heap->segments_list = NULL;
|
||||
zend_mm_init(heap);
|
||||
heap->real_size = 0;
|
||||
#if MEMORY_LIMIT
|
||||
heap->real_peak = 0;
|
||||
heap->size = 0;
|
||||
heap->peak = 0;
|
||||
heap->reserve = zend_mm_alloc(heap, ZEND_MM_RESERVE_SIZE);
|
||||
#endif
|
||||
heap->overflow = 0;
|
||||
}
|
||||
}
|
||||
@ -1291,12 +1272,10 @@ static void zend_mm_safe_error(zend_mm_heap *heap,
|
||||
#endif
|
||||
size_t size)
|
||||
{
|
||||
#if MEMORY_LIMIT
|
||||
if (heap->reserve) {
|
||||
zend_mm_free(heap, heap->reserve);
|
||||
heap->reserve = NULL;
|
||||
}
|
||||
#endif
|
||||
if (heap->overflow == 0) {
|
||||
char *error_filename;
|
||||
uint error_lineno;
|
||||
@ -1452,7 +1431,6 @@ zend_mm_finished_searching_for_block:
|
||||
|
||||
HANDLE_BLOCK_INTERRUPTIONS();
|
||||
|
||||
#if MEMORY_LIMIT
|
||||
if (heap->real_size + segment_size > heap->limit) {
|
||||
/* Memory limit overflow */
|
||||
#if ZEND_MM_CACHE
|
||||
@ -1465,7 +1443,6 @@ zend_mm_finished_searching_for_block:
|
||||
zend_mm_safe_error(heap, "Allowed memory size of %d bytes exhausted (tried to allocate %d bytes)", heap->limit, size);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
segment = (zend_mm_segment *) ZEND_MM_STORAGE_ALLOC(segment_size);
|
||||
|
||||
@ -1484,11 +1461,9 @@ zend_mm_finished_searching_for_block:
|
||||
}
|
||||
|
||||
heap->real_size += segment_size;
|
||||
#if MEMORY_LIMIT
|
||||
if (heap->real_size > heap->real_peak) {
|
||||
heap->real_peak = heap->real_size;
|
||||
}
|
||||
#endif
|
||||
|
||||
segment->size = segment_size;
|
||||
segment->next_segment = heap->segments_list;
|
||||
@ -1520,12 +1495,10 @@ zend_mm_finished_searching_for_block:
|
||||
|
||||
ZEND_MM_SET_DEBUG_INFO(best_fit, size, 1, 1);
|
||||
|
||||
#if MEMORY_LIMIT
|
||||
heap->size += true_size;
|
||||
if (heap->peak < heap->size) {
|
||||
heap->peak = heap->size;
|
||||
}
|
||||
#endif
|
||||
|
||||
HANDLE_UNBLOCK_INTERRUPTIONS();
|
||||
|
||||
@ -1565,9 +1538,7 @@ static void _zend_mm_free_int(zend_mm_heap *heap, void *p ZEND_FILE_LINE_DC ZEND
|
||||
|
||||
HANDLE_BLOCK_INTERRUPTIONS();
|
||||
|
||||
#if MEMORY_LIMIT
|
||||
heap->size -= size;
|
||||
#endif
|
||||
|
||||
if (ZEND_MM_PREV_BLOCK_IS_FREE(mm_block)) {
|
||||
next_block = ZEND_MM_NEXT_BLOCK(mm_block);
|
||||
@ -1665,9 +1636,7 @@ static void *_zend_mm_realloc_int(zend_mm_heap *heap, void *p, size_t size ZEND_
|
||||
|
||||
/* add the new free block to the free list */
|
||||
zend_mm_add_to_free_list(heap, new_free_block);
|
||||
#if MEMORY_LIMIT
|
||||
heap->size += (true_size - orig_size);
|
||||
#endif
|
||||
HANDLE_UNBLOCK_INTERRUPTIONS();
|
||||
}
|
||||
ZEND_MM_SET_DEBUG_INFO(mm_block, size, 0, 0);
|
||||
@ -1701,12 +1670,10 @@ static void *_zend_mm_realloc_int(zend_mm_heap *heap, void *p, size_t size ZEND_
|
||||
zend_mm_add_to_free_list(heap, new_free_block);
|
||||
}
|
||||
ZEND_MM_SET_DEBUG_INFO(mm_block, size, 0, 0);
|
||||
#if MEMORY_LIMIT
|
||||
heap->size = heap->size + true_size - orig_size;
|
||||
if (heap->peak < heap->size) {
|
||||
heap->peak = heap->size;
|
||||
}
|
||||
#endif
|
||||
HANDLE_UNBLOCK_INTERRUPTIONS();
|
||||
return p;
|
||||
} else if (ZEND_MM_IS_FIRST_BLOCK(mm_block) &&
|
||||
@ -1733,7 +1700,6 @@ realloc_segment:
|
||||
}
|
||||
|
||||
segment_copy = (zend_mm_segment *) ((char *)mm_block - ZEND_MM_ALIGNED_SEGMENT_SIZE);
|
||||
#if MEMORY_LIMIT
|
||||
if (heap->real_size + segment_size - segment_copy->size > heap->limit) {
|
||||
#if ZEND_MM_CACHE
|
||||
zend_mm_free_cache(heap);
|
||||
@ -1746,7 +1712,7 @@ realloc_segment:
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
segment = ZEND_MM_STORAGE_REALLOC(segment_copy, segment_size);
|
||||
if (!segment) {
|
||||
#if ZEND_MM_CACHE
|
||||
@ -1761,11 +1727,10 @@ realloc_segment:
|
||||
return NULL;
|
||||
}
|
||||
heap->real_size += segment_size - segment->size;
|
||||
#if MEMORY_LIMIT
|
||||
if (heap->real_size > heap->real_peak) {
|
||||
heap->real_peak = heap->real_size;
|
||||
}
|
||||
#endif
|
||||
|
||||
segment->size = segment_size;
|
||||
|
||||
if (segment != segment_copy) {
|
||||
@ -1808,12 +1773,12 @@ realloc_segment:
|
||||
}
|
||||
|
||||
ZEND_MM_SET_DEBUG_INFO(mm_block, size, 1, 1);
|
||||
#if MEMORY_LIMIT
|
||||
|
||||
heap->size = heap->size + true_size - orig_size;
|
||||
if (heap->peak < heap->size) {
|
||||
heap->peak = heap->size;
|
||||
}
|
||||
#endif
|
||||
|
||||
HANDLE_UNBLOCK_INTERRUPTIONS();
|
||||
return ZEND_MM_DATA_OF(mm_block);
|
||||
}
|
||||
@ -1877,22 +1842,16 @@ static zend_alloc_globals alloc_globals;
|
||||
|
||||
ZEND_API int is_zend_mm(TSRMLS_D)
|
||||
{
|
||||
#if ZEND_USE_MALLOC_MM
|
||||
return AG(mm_heap)->use_zend_alloc;
|
||||
#else
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
ZEND_API void *_emalloc(size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
|
||||
{
|
||||
TSRMLS_FETCH();
|
||||
|
||||
#if ZEND_USE_MALLOC_MM
|
||||
if (!AG(mm_heap)->use_zend_alloc) {
|
||||
return malloc(size);
|
||||
}
|
||||
#endif
|
||||
return _zend_mm_alloc_int(AG(mm_heap), size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
|
||||
}
|
||||
|
||||
@ -1900,12 +1859,10 @@ ZEND_API void _efree(void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
|
||||
{
|
||||
TSRMLS_FETCH();
|
||||
|
||||
#if ZEND_USE_MALLOC_MM
|
||||
if (!AG(mm_heap)->use_zend_alloc) {
|
||||
free(ptr);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
_zend_mm_free_int(AG(mm_heap), ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
|
||||
}
|
||||
|
||||
@ -1913,21 +1870,17 @@ ZEND_API void *_erealloc(void *ptr, size_t size, int allow_failure ZEND_FILE_LIN
|
||||
{
|
||||
TSRMLS_FETCH();
|
||||
|
||||
#if ZEND_USE_MALLOC_MM
|
||||
if (!AG(mm_heap)->use_zend_alloc) {
|
||||
return realloc(ptr, size);
|
||||
}
|
||||
#endif
|
||||
return _zend_mm_realloc_int(AG(mm_heap), ptr, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
|
||||
}
|
||||
|
||||
ZEND_API size_t _zend_mem_block_size(void *ptr TSRMLS_DC ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
|
||||
{
|
||||
#if ZEND_USE_MALLOC_MM
|
||||
if (!AG(mm_heap)->use_zend_alloc) {
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
return _zend_mm_block_size(AG(mm_heap), ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
|
||||
}
|
||||
|
||||
@ -2083,14 +2036,10 @@ ZEND_API UChar *zend_ustrndup(const UChar *s, uint length)
|
||||
|
||||
ZEND_API int zend_set_memory_limit(unsigned int memory_limit)
|
||||
{
|
||||
#if MEMORY_LIMIT
|
||||
TSRMLS_FETCH();
|
||||
|
||||
AG(mm_heap)->limit = memory_limit;
|
||||
return SUCCESS;
|
||||
#else
|
||||
return FAILURE;
|
||||
#endif
|
||||
}
|
||||
|
||||
ZEND_API size_t zend_memory_usage(int real_usage TSRMLS_DC)
|
||||
@ -2098,25 +2047,17 @@ ZEND_API size_t zend_memory_usage(int real_usage TSRMLS_DC)
|
||||
if (real_usage) {
|
||||
return AG(mm_heap)->real_size;
|
||||
} else {
|
||||
#if MEMORY_LIMIT
|
||||
return AG(mm_heap)->size;
|
||||
#else
|
||||
return AG(mm_heap)->real_size;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
ZEND_API size_t zend_memory_peak_usage(int real_usage TSRMLS_DC)
|
||||
{
|
||||
#if MEMORY_LIMIT
|
||||
if (real_usage) {
|
||||
return AG(mm_heap)->real_peak;
|
||||
} else {
|
||||
return AG(mm_heap)->peak;
|
||||
}
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -2127,15 +2068,13 @@ ZEND_API void shutdown_memory_manager(int silent, int full_shutdown TSRMLS_DC)
|
||||
|
||||
static void alloc_globals_ctor(zend_alloc_globals *alloc_globals TSRMLS_DC)
|
||||
{
|
||||
char *tmp;
|
||||
alloc_globals->mm_heap = zend_mm_startup();
|
||||
#if ZEND_USE_MALLOC_MM
|
||||
{
|
||||
char *tmp = getenv("USE_ZEND_ALLOC");
|
||||
if (tmp) {
|
||||
alloc_globals->mm_heap->use_zend_alloc = zend_atoi(tmp, 0);
|
||||
}
|
||||
|
||||
tmp = getenv("USE_ZEND_ALLOC");
|
||||
if (tmp) {
|
||||
alloc_globals->mm_heap->use_zend_alloc = zend_atoi(tmp, 0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef ZTS
|
||||
@ -2169,11 +2108,9 @@ ZEND_API int _mem_block_check(void *ptr, int silent ZEND_FILE_LINE_DC ZEND_FILE_
|
||||
{
|
||||
TSRMLS_FETCH();
|
||||
|
||||
#if ZEND_USE_MALLOC_MM
|
||||
if (!AG(mm_heap)->use_zend_alloc) {
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
return zend_mm_check_ptr(AG(mm_heap), ptr, silent ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
|
||||
}
|
||||
|
||||
@ -2183,11 +2120,9 @@ ZEND_API void _full_mem_check(int silent ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_D
|
||||
int errors;
|
||||
TSRMLS_FETCH();
|
||||
|
||||
#if ZEND_USE_MALLOC_MM
|
||||
if (!AG(mm_heap)->use_zend_alloc) {
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
zend_debug_alloc_output("------------------------------------------------\n");
|
||||
zend_debug_alloc_output("Full Memory Check at %s:%d\n" ZEND_FILE_LINE_RELAY_CC);
|
||||
|
@ -3109,7 +3109,6 @@ ZEND_BEGIN_ARG_INFO(arginfo_unserialize, 0)
|
||||
ZEND_ARG_INFO(0, variable_representation)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
#if MEMORY_LIMIT
|
||||
static
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_memory_get_usage, 0, 0, 0)
|
||||
ZEND_ARG_INFO(0, real_usage)
|
||||
@ -3119,7 +3118,6 @@ static
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_memory_get_peak_usage, 0, 0, 0)
|
||||
ZEND_ARG_INFO(0, real_usage)
|
||||
ZEND_END_ARG_INFO()
|
||||
#endif
|
||||
/* }}} */
|
||||
/* {{{ versioning.c */
|
||||
static
|
||||
@ -3435,10 +3433,8 @@ zend_function_entry basic_functions[] = {
|
||||
PHP_FE(var_export, arginfo_var_export)
|
||||
PHP_FE(debug_zval_dump, arginfo_debug_zval_dump)
|
||||
PHP_FE(print_r, arginfo_print_r)
|
||||
#if MEMORY_LIMIT
|
||||
PHP_FE(memory_get_usage, arginfo_memory_get_usage)
|
||||
PHP_FE(memory_get_peak_usage, arginfo_memory_get_peak_usage)
|
||||
#endif
|
||||
|
||||
PHP_FE(register_shutdown_function, arginfo_register_shutdown_function)
|
||||
PHP_FE(register_tick_function, arginfo_register_tick_function)
|
||||
|
@ -29,10 +29,8 @@ PHP_FUNCTION(var_export);
|
||||
PHP_FUNCTION(debug_zval_dump);
|
||||
PHP_FUNCTION(serialize);
|
||||
PHP_FUNCTION(unserialize);
|
||||
#if MEMORY_LIMIT
|
||||
PHP_FUNCTION(memory_get_usage);
|
||||
PHP_FUNCTION(memory_get_peak_usage);
|
||||
#endif
|
||||
|
||||
PHPAPI void php_var_dump(zval **struc, int level, int verbose TSRMLS_DC);
|
||||
PHPAPI void php_var_export(zval **struc, int level TSRMLS_DC);
|
||||
|
@ -1187,7 +1187,6 @@ PHP_FUNCTION(unserialize)
|
||||
|
||||
/* }}} */
|
||||
|
||||
#if MEMORY_LIMIT
|
||||
/* {{{ proto int memory_get_usage([real_usage]) U
|
||||
Returns the allocated by PHP memory */
|
||||
PHP_FUNCTION(memory_get_usage) {
|
||||
@ -1200,6 +1199,7 @@ PHP_FUNCTION(memory_get_usage) {
|
||||
RETURN_LONG(zend_memory_usage(real_usage TSRMLS_CC));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto int memory_get_peak_usage([real_usage]) U
|
||||
Returns the peak allocated by PHP memory */
|
||||
PHP_FUNCTION(memory_get_peak_usage) {
|
||||
@ -1212,7 +1212,6 @@ PHP_FUNCTION(memory_get_peak_usage) {
|
||||
RETURN_LONG(zend_memory_peak_usage(real_usage TSRMLS_CC));
|
||||
}
|
||||
/* }}} */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
|
@ -105,7 +105,6 @@ static PHP_INI_MH(OnSetPrecision)
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
#if MEMORY_LIMIT
|
||||
/* {{{ PHP_INI_MH
|
||||
*/
|
||||
static PHP_INI_MH(OnChangeMemoryLimit)
|
||||
@ -118,7 +117,6 @@ static PHP_INI_MH(OnChangeMemoryLimit)
|
||||
return zend_set_memory_limit(PG(memory_limit));
|
||||
}
|
||||
/* }}} */
|
||||
#endif
|
||||
|
||||
|
||||
/* {{{ php_disable_functions
|
||||
@ -409,9 +407,7 @@ PHP_INI_BEGIN()
|
||||
PHP_INI_ENTRY("SMTP", "localhost",PHP_INI_ALL, NULL)
|
||||
PHP_INI_ENTRY("smtp_port", "25", PHP_INI_ALL, NULL)
|
||||
PHP_INI_ENTRY("browscap", NULL, PHP_INI_SYSTEM, NULL)
|
||||
#if MEMORY_LIMIT
|
||||
PHP_INI_ENTRY("memory_limit", "16M", PHP_INI_ALL, OnChangeMemoryLimit)
|
||||
#endif
|
||||
PHP_INI_ENTRY("precision", "14", PHP_INI_ALL, OnSetPrecision)
|
||||
PHP_INI_ENTRY("sendmail_from", NULL, PHP_INI_ALL, NULL)
|
||||
PHP_INI_ENTRY("sendmail_path", DEFAULT_SENDMAIL_PATH, PHP_INI_SYSTEM, NULL)
|
||||
@ -929,10 +925,8 @@ static void php_error_cb(int type, const char *error_filename, const uint error_
|
||||
case E_USER_ERROR:
|
||||
EG(exit_status) = 255;
|
||||
if (module_initialized) {
|
||||
#if MEMORY_LIMIT
|
||||
/* restore memory limit */
|
||||
zend_set_memory_limit(PG(memory_limit));
|
||||
#endif
|
||||
efree(buffer);
|
||||
zend_objects_store_mark_destructed(&EG(objects_store) TSRMLS_CC);
|
||||
zend_bailout();
|
||||
|
@ -52,13 +52,8 @@ static HashTable php_output_handler_reverse_conflicts;
|
||||
static inline int php_output_lock_error(int op TSRMLS_DC);
|
||||
static inline void php_output_op(int op, const char *str, size_t len TSRMLS_DC);
|
||||
|
||||
#if MEMORY_LIMIT
|
||||
#define php_output_handler_init(n, cs, f) php_output_handler_init_ex((n), (cs), (f) TSRMLS_CC)
|
||||
static inline php_output_handler *php_output_handler_init_ex(zval *name, size_t chunk_size, int flags TSRMLS_DC);
|
||||
#else
|
||||
#define php_output_handler_init php_output_handler_init_ex
|
||||
static inline php_output_handler *php_output_handler_init_ex(zval *name, size_t chunk_size, int flags);
|
||||
#endif
|
||||
static inline php_output_handler_status_t php_output_handler_op(php_output_handler *handler, php_output_context *context);
|
||||
static inline int php_output_handler_append(php_output_handler *handler, const php_output_buffer *buf TSRMLS_DC);
|
||||
static inline zval *php_output_handler_status(php_output_handler *handler, zval *entry);
|
||||
@ -889,29 +884,23 @@ static inline void php_output_context_dtor(php_output_context *context)
|
||||
|
||||
/* {{{ static php_output_handler *php_output_handler_init(zval *name, size_t chunk_size, int flags)
|
||||
Allocates and initializes a php_output_handler structure */
|
||||
#if MEMORY_LIMIT
|
||||
static inline php_output_handler *php_output_handler_init_ex(zval *name, size_t chunk_size, int flags TSRMLS_DC)
|
||||
#else
|
||||
static inline php_output_handler *php_output_handler_init_ex(zval *name, size_t chunk_size, int flags)
|
||||
#endif
|
||||
{
|
||||
php_output_handler *handler;
|
||||
#if MEMORY_LIMIT
|
||||
size_t mem_limit;
|
||||
#endif
|
||||
|
||||
handler = ecalloc(1, sizeof(php_output_handler));
|
||||
ZVAL_ADDREF(name);
|
||||
handler->name = name;
|
||||
|
||||
#if MEMORY_LIMIT
|
||||
mem_limit = (PG(memory_limit) - zend_memory_usage(1 TSRMLS_CC)) / 2;
|
||||
if (!chunk_size || chunk_size > mem_limit) {
|
||||
handler->size = mem_limit;
|
||||
chunk_size = 0;
|
||||
} else
|
||||
#endif
|
||||
handler->size = chunk_size;
|
||||
} else {
|
||||
handler->size = chunk_size;
|
||||
}
|
||||
|
||||
handler->flags = flags;
|
||||
handler->buffer.size = PHP_OUTPUT_HANDLER_INITBUF_SIZE(chunk_size);
|
||||
handler->buffer.data = emalloc(handler->buffer.size);
|
||||
|
@ -661,16 +661,10 @@ static int send_php(request_rec *r, int display_source_mode, char *filename)
|
||||
static int send_parsed_php(request_rec * r)
|
||||
{
|
||||
int result = send_php(r, 0, NULL);
|
||||
|
||||
#if MEMORY_LIMIT
|
||||
{
|
||||
char *mem_usage;
|
||||
TSRMLS_FETCH();
|
||||
TSRMLS_FETCH();
|
||||
|
||||
mem_usage = ap_psprintf(r->pool, "%u", zend_memory_peak_usage(1 TSRMLS_CC));
|
||||
ap_table_setn(r->notes, "mod_php_memory_usage", mem_usage);
|
||||
}
|
||||
#endif
|
||||
ap_table_setn(r->notes, "mod_php_memory_usage",
|
||||
ap_psprintf(r->pool, "%u", zend_memory_peak_usage(1 TSRMLS_CC)));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -525,14 +525,9 @@ static int php_output_filter(ap_filter_t *f, apr_bucket_brigade *bb)
|
||||
zfd.opened_path = NULL;
|
||||
|
||||
php_execute_script(&zfd TSRMLS_CC);
|
||||
#if MEMORY_LIMIT
|
||||
{
|
||||
char *mem_usage;
|
||||
|
||||
mem_usage = apr_psprintf(ctx->r->pool, "%u", zend_memory_peak_usage(1 TSRMLS_CC));
|
||||
apr_table_set(ctx->r->notes, "mod_php_memory_usage", mem_usage);
|
||||
}
|
||||
#endif
|
||||
|
||||
apr_table_set(ctx->r->notes, "mod_php_memory_usage",
|
||||
apr_psprintf(ctx->r->pool, "%u", zend_memory_peak_usage(1 TSRMLS_CC)));
|
||||
} else {
|
||||
zend_syntax_highlighter_ini syntax_highlighter_ini;
|
||||
|
||||
|
@ -619,14 +619,9 @@ zend_first_try {
|
||||
} else {
|
||||
zend_execute_scripts(ZEND_INCLUDE TSRMLS_CC, NULL, 1, &zfd);
|
||||
}
|
||||
#if MEMORY_LIMIT
|
||||
{
|
||||
char *mem_usage;
|
||||
|
||||
mem_usage = apr_psprintf(ctx->r->pool, "%u", zend_memory_peak_usage(1 TSRMLS_CC));
|
||||
apr_table_set(r->notes, "mod_php_memory_usage", mem_usage);
|
||||
}
|
||||
#endif
|
||||
apr_table_set(r->notes, "mod_php_memory_usage",
|
||||
apr_psprintf(ctx->r->pool, "%u", zend_memory_peak_usage(1 TSRMLS_CC)));
|
||||
}
|
||||
|
||||
} zend_end_try();
|
||||
|
@ -721,16 +721,10 @@ static int send_php(request_rec *r, int display_source_mode, char *filename)
|
||||
static int send_parsed_php(request_rec * r)
|
||||
{
|
||||
int result = send_php(r, 0, NULL);
|
||||
|
||||
#if MEMORY_LIMIT
|
||||
{
|
||||
char *mem_usage;
|
||||
TSRMLS_FETCH();
|
||||
TSRMLS_FETCH();
|
||||
|
||||
mem_usage = ap_psprintf(r->pool, "%u", zend_memory_peak_usage(1 TSRMLS_CC));
|
||||
ap_table_setn(r->notes, "mod_php_memory_usage", mem_usage);
|
||||
}
|
||||
#endif
|
||||
ap_table_setn(r->notes, "mod_php_memory_usage",
|
||||
ap_psprintf(r->pool, "%u", zend_memory_peak_usage(1 TSRMLS_CC)));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -314,14 +314,6 @@ AC_DEFINE('HAVE_IPV6', main_network_has_ipv6);
|
||||
ARG_ENABLE('fd-setsize', "Set maximum number of sockets for select(2)", "256");
|
||||
ADD_FLAG("CFLAGS", "/D FD_SETSIZE=" + parseInt(PHP_FD_SETSIZE));
|
||||
|
||||
ARG_ENABLE("memory-limit", "Enable memory limit checking code", "no");
|
||||
AC_DEFINE('MEMORY_LIMIT', PHP_MEMORY_LIMIT == "yes" ? 1 : 0);
|
||||
|
||||
ARG_ENABLE("malloc-mm", "Use environment variable for run-time malloc/emalloc selection", "");
|
||||
if (PHP_MALLOC_MM.length) {
|
||||
AC_DEFINE('ZEND_USE_MALLOC_MM', PHP_MALLOC_MM == "yes" ? 1 : 0);
|
||||
}
|
||||
|
||||
AC_DEFINE('HAVE_USLEEP', 1);
|
||||
AC_DEFINE('HAVE_STRCOLL', 1);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user