@@ -852,7 +852,7 @@ static void zend_accel_schedule_restart_if_necessary(TSRMLS_D)
852
852
{
853
853
if ((((double ) ZSMMG (wasted_shared_memory )) / ZCG (accel_directives ).memory_consumption ) >= ZCG (accel_directives ).max_wasted_percentage ) {
854
854
ZSMMG (memory_exhausted ) = 1 ;
855
- zend_accel_schedule_restart (TSRMLS_C );
855
+ zend_accel_schedule_restart (ACCEL_RESTART_WASTED TSRMLS_CC );
856
856
}
857
857
}
858
858
@@ -1030,7 +1030,7 @@ static void zend_accel_add_key(char *key, unsigned int key_length, zend_accel_ha
1030
1030
if (zend_accel_hash_is_full (& ZCSG (hash ))) {
1031
1031
zend_accel_error (ACCEL_LOG_DEBUG , "No more entries in hash table!" );
1032
1032
ZSMMG (memory_exhausted ) = 1 ;
1033
- zend_accel_schedule_restart (TSRMLS_C );
1033
+ zend_accel_schedule_restart (ACCEL_RESTART_HASH TSRMLS_CC );
1034
1034
} else {
1035
1035
char * new_key = zend_shared_alloc (key_length + 1 );
1036
1036
if (new_key ) {
@@ -1057,7 +1057,7 @@ static zend_persistent_script *cache_script_in_shared_memory(zend_persistent_scr
1057
1057
if (zend_accel_hash_is_full (& ZCSG (hash ))) {
1058
1058
zend_accel_error (ACCEL_LOG_DEBUG , "No more entries in hash table!" );
1059
1059
ZSMMG (memory_exhausted ) = 1 ;
1060
- zend_accel_schedule_restart (TSRMLS_C );
1060
+ zend_accel_schedule_restart (ACCEL_RESTART_HASH TSRMLS_CC );
1061
1061
zend_shared_alloc_unlock (TSRMLS_C );
1062
1062
return new_persistent_script ;
1063
1063
}
@@ -1118,7 +1118,7 @@ static zend_persistent_script *cache_script_in_shared_memory(zend_persistent_scr
1118
1118
if (!zend_accel_hash_update (& ZCSG (hash ), key , key_length + 1 , 1 , bucket )) {
1119
1119
zend_accel_error (ACCEL_LOG_DEBUG , "No more entries in hash table!" );
1120
1120
ZSMMG (memory_exhausted ) = 1 ;
1121
- zend_accel_schedule_restart (TSRMLS_C );
1121
+ zend_accel_schedule_restart (ACCEL_RESTART_HASH TSRMLS_CC );
1122
1122
}
1123
1123
}
1124
1124
@@ -1500,7 +1500,7 @@ static zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int
1500
1500
ZCSG (misses )++ ;
1501
1501
1502
1502
/* No memory left. Behave like without the Accelerator */
1503
- if (ZSMMG (memory_exhausted )) {
1503
+ if (ZSMMG (memory_exhausted ) || ZCSG ( restart_pending ) ) {
1504
1504
SHM_PROTECT ();
1505
1505
return accelerator_orig_compile_file (file_handle , type TSRMLS_CC );
1506
1506
}
@@ -1964,6 +1964,20 @@ static void accel_activate(void)
1964
1964
if (accel_is_inactive (TSRMLS_C ) == SUCCESS ) {
1965
1965
zend_accel_error (ACCEL_LOG_DEBUG , "Restarting!" );
1966
1966
ZCSG (restart_pending ) = 0 ;
1967
+ switch ZCSG (restart_reason ) {
1968
+ case ACCEL_RESTART_OOM :
1969
+ ZCSG (oom_restarts )++ ;
1970
+ break ;
1971
+ case ACCEL_RESTART_WASTED :
1972
+ ZCSG (wasted_restarts )++ ;
1973
+ break ;
1974
+ case ACCEL_RESTART_HASH :
1975
+ ZCSG (hash_restarts )++ ;
1976
+ break ;
1977
+ case ACCEL_RESTART_USER :
1978
+ ZCSG (manual_restarts )++ ;
1979
+ break ;
1980
+ }
1967
1981
accel_restart_enter (TSRMLS_C );
1968
1982
1969
1983
zend_reset_cache_vars (TSRMLS_C );
@@ -2322,8 +2336,13 @@ static void zend_accel_init_shm(TSRMLS_D)
2322
2336
2323
2337
zend_reset_cache_vars (TSRMLS_C );
2324
2338
2339
+ ZCSG (oom_restarts ) = 0 ;
2340
+ ZCSG (wasted_restarts ) = 0 ;
2341
+ ZCSG (hash_restarts ) = 0 ;
2342
+ ZCSG (manual_restarts ) = 0 ;
2343
+
2325
2344
ZCSG (accelerator_enabled ) = 1 ;
2326
- ZCSG (last_restart_time ) = 0 ;
2345
+ ZCSG (last_restart_time ) = zend_accel_get_time () ;
2327
2346
ZCSG (restart_in_progress ) = 0 ;
2328
2347
2329
2348
zend_shared_alloc_unlock (TSRMLS_C );
@@ -2547,7 +2566,7 @@ static void accel_shutdown(zend_extension *extension)
2547
2566
2548
2567
}
2549
2568
2550
- void zend_accel_schedule_restart (TSRMLS_D )
2569
+ void zend_accel_schedule_restart (zend_accel_restart_reason reason TSRMLS_DC )
2551
2570
{
2552
2571
if (ZCSG (restart_pending )) {
2553
2572
/* don't schedule twice */
@@ -2556,6 +2575,7 @@ void zend_accel_schedule_restart(TSRMLS_D)
2556
2575
zend_accel_error (ACCEL_LOG_DEBUG , "Restart Scheduled!" );
2557
2576
2558
2577
ZCSG (restart_pending ) = 1 ;
2578
+ ZCSG (restart_reason ) = reason ;
2559
2579
ZCSG (cache_status_before_restart ) = ZCSG (accelerator_enabled );
2560
2580
ZCSG (accelerator_enabled ) = 0 ;
2561
2581
0 commit comments