@@ -71,8 +71,6 @@ typedef int gid_t;
71
71
#include <sys/stat.h>
72
72
#include <errno.h>
73
73
74
- #define MIN_FREE_MEMORY 64*1024
75
-
76
74
#define SHM_PROTECT () \
77
75
do { \
78
76
if (ZCG(accel_directives).protect_memory) { \
@@ -853,6 +851,7 @@ static inline int do_validate_timestamps(zend_persistent_script *persistent_scri
853
851
static void zend_accel_schedule_restart_if_necessary (TSRMLS_D )
854
852
{
855
853
if ((((double ) ZSMMG (wasted_shared_memory )) / ZCG (accel_directives ).memory_consumption ) >= ZCG (accel_directives ).max_wasted_percentage ) {
854
+ ZSMMG (memory_exhausted ) = 1 ;
856
855
zend_accel_schedule_restart (TSRMLS_C );
857
856
}
858
857
}
@@ -1031,14 +1030,12 @@ static void zend_accel_add_key(char *key, unsigned int key_length, zend_accel_ha
1031
1030
if (zend_accel_hash_is_full (& ZCSG (hash ))) {
1032
1031
zend_accel_error (ACCEL_LOG_DEBUG , "No more entries in hash table!" );
1033
1032
ZSMMG (memory_exhausted ) = 1 ;
1033
+ zend_accel_schedule_restart (TSRMLS_C );
1034
1034
} else {
1035
1035
char * new_key = zend_shared_alloc (key_length + 1 );
1036
1036
if (new_key ) {
1037
1037
memcpy (new_key , key , key_length + 1 );
1038
1038
zend_accel_hash_update (& ZCSG (hash ), new_key , key_length + 1 , 1 , bucket );
1039
- } else {
1040
- zend_accel_error (ACCEL_LOG_DEBUG , "No more memory!" );
1041
- ZSMMG (memory_exhausted ) = 1 ;
1042
1039
}
1043
1040
}
1044
1041
}
@@ -1060,7 +1057,7 @@ static zend_persistent_script *cache_script_in_shared_memory(zend_persistent_scr
1060
1057
if (zend_accel_hash_is_full (& ZCSG (hash ))) {
1061
1058
zend_accel_error (ACCEL_LOG_DEBUG , "No more entries in hash table!" );
1062
1059
ZSMMG (memory_exhausted ) = 1 ;
1063
- zend_accel_schedule_restart_if_necessary (TSRMLS_C );
1060
+ zend_accel_schedule_restart (TSRMLS_C );
1064
1061
zend_shared_alloc_unlock (TSRMLS_C );
1065
1062
return new_persistent_script ;
1066
1063
}
@@ -1088,11 +1085,6 @@ static zend_persistent_script *cache_script_in_shared_memory(zend_persistent_scr
1088
1085
/* Allocate shared memory */
1089
1086
ZCG (mem ) = zend_shared_alloc (memory_used );
1090
1087
if (!ZCG (mem )) {
1091
- zend_accel_error (ACCEL_LOG_DEBUG , "No more memory!" );
1092
- zend_accel_schedule_restart_if_necessary (TSRMLS_C );
1093
- if (zend_shared_alloc_get_largest_free_block () < MIN_FREE_MEMORY ) {
1094
- ZSMMG (memory_exhausted ) = 1 ;
1095
- }
1096
1088
zend_shared_alloc_unlock (TSRMLS_C );
1097
1089
return new_persistent_script ;
1098
1090
}
@@ -1126,6 +1118,7 @@ static zend_persistent_script *cache_script_in_shared_memory(zend_persistent_scr
1126
1118
if (!zend_accel_hash_update (& ZCSG (hash ), key , key_length + 1 , 1 , bucket )) {
1127
1119
zend_accel_error (ACCEL_LOG_DEBUG , "No more entries in hash table!" );
1128
1120
ZSMMG (memory_exhausted ) = 1 ;
1121
+ zend_accel_schedule_restart (TSRMLS_C );
1129
1122
}
1130
1123
}
1131
1124
@@ -1469,6 +1462,7 @@ static zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int
1469
1462
persistent_script -> corrupted = 1 ;
1470
1463
persistent_script -> timestamp = 0 ;
1471
1464
ZSMMG (wasted_shared_memory ) += persistent_script -> dynamic_members .memory_consumption ;
1465
+ zend_accel_schedule_restart_if_necessary (TSRMLS_C );
1472
1466
}
1473
1467
zend_shared_alloc_unlock (TSRMLS_C );
1474
1468
persistent_script = NULL ;
@@ -1489,6 +1483,7 @@ static zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int
1489
1483
persistent_script -> corrupted = 1 ;
1490
1484
persistent_script -> timestamp = 0 ;
1491
1485
ZSMMG (wasted_shared_memory ) += persistent_script -> dynamic_members .memory_consumption ;
1486
+ zend_accel_schedule_restart_if_necessary (TSRMLS_C );
1492
1487
}
1493
1488
zend_shared_alloc_unlock (TSRMLS_C );
1494
1489
persistent_script = NULL ;
0 commit comments