4848#include "zend_accelerator_hash.h"
4949#include "zend_file_cache.h"
5050#include "zend_system_id.h"
51+ #include "zend_time.h"
5152#include "ext/pcre/php_pcre.h"
5253#include "ext/standard/basic_functions.h"
5354
@@ -73,9 +74,7 @@ typedef int gid_t;
7374#include <lmcons.h>
7475#endif
7576
76- #ifndef ZEND_WIN32
77- # include <sys/time.h>
78- #else
77+ #ifdef ZEND_WIN32
7978# include <process.h>
8079#endif
8180
@@ -84,7 +83,6 @@ typedef int gid_t;
8483#endif
8584#include <fcntl.h>
8685#include <signal.h>
87- #include <time.h>
8886
8987#ifndef ZEND_WIN32
9088# include <sys/types.h>
@@ -191,18 +189,6 @@ static void bzero_aligned(void *mem, size_t size)
191189#endif
192190}
193191
194- #ifdef ZEND_WIN32
195- static time_t zend_accel_get_time (void )
196- {
197- FILETIME now ;
198- GetSystemTimeAsFileTime (& now );
199-
200- return (time_t ) ((((((__int64 )now .dwHighDateTime ) << 32 )|now .dwLowDateTime ) - 116444736000000000L )/10000000 );
201- }
202- #else
203- # define zend_accel_get_time () time(NULL)
204- #endif
205-
206192static inline bool is_cacheable_stream_path (const char * filename )
207193{
208194 return memcmp (filename , "file://" , sizeof ("file://" ) - 1 ) == 0 ||
@@ -878,7 +864,7 @@ static inline void kill_all_lockers(struct flock *mem_usage_check)
878864 }
879865 if (!success ) {
880866 /* errno is not ESRCH or we ran out of tries to kill the locker */
881- ZCSG (force_restart_time ) = time ( NULL ); /* restore forced restart request */
867+ ZCSG (force_restart_time ) = zend_realtime_get ( ); /* restore forced restart request */
882868 /* cannot kill the locker, bail out with error */
883869 zend_accel_error_noreturn (ACCEL_LOG_ERROR , "Cannot kill process %d!" , mem_usage_check -> l_pid );
884870 }
@@ -915,6 +901,7 @@ static inline bool accel_is_inactive(void)
915901 }
916902#else
917903 struct flock mem_usage_check ;
904+ time_t now ;
918905
919906 mem_usage_check .l_type = F_WRLCK ;
920907 mem_usage_check .l_whence = SEEK_SET ;
@@ -931,8 +918,8 @@ static inline bool accel_is_inactive(void)
931918
932919 if (ZCG (accel_directives ).force_restart_timeout
933920 && ZCSG (force_restart_time )
934- && time ( NULL ) >= ZCSG (force_restart_time )) {
935- zend_accel_error (ACCEL_LOG_WARNING , "Forced restart at %ld (after " ZEND_LONG_FMT " seconds), locked by %d" , (long ) time ( NULL ) , ZCG (accel_directives ).force_restart_timeout , mem_usage_check .l_pid );
921+ && ( now = zend_realtime_get () ) >= ZCSG (force_restart_time )) {
922+ zend_accel_error (ACCEL_LOG_WARNING , "Forced restart at %lld (after " ZEND_LONG_FMT " seconds), locked by %d" , (long long ) now , ZCG (accel_directives ).force_restart_timeout , mem_usage_check .l_pid );
936923 kill_all_lockers (& mem_usage_check );
937924
938925 return false; /* next request should be able to restart it */
@@ -2929,7 +2916,7 @@ static zend_result zend_accel_init_shm(void)
29292916 ZCSG (manual_restarts ) = 0 ;
29302917
29312918 ZCSG (accelerator_enabled ) = true;
2932- ZCSG (start_time ) = zend_accel_get_time ();
2919+ ZCSG (start_time ) = zend_realtime_get ();
29332920 ZCSG (last_restart_time ) = 0 ;
29342921 ZCSG (restart_in_progress ) = false;
29352922
@@ -3545,7 +3532,7 @@ void zend_accel_schedule_restart(zend_accel_restart_reason reason)
35453532 ZCSG (accelerator_enabled ) = false;
35463533
35473534 if (ZCG (accel_directives ).force_restart_timeout ) {
3548- ZCSG (force_restart_time ) = zend_accel_get_time () + ZCG (accel_directives ).force_restart_timeout ;
3535+ ZCSG (force_restart_time ) = zend_realtime_get () + ZCG (accel_directives ).force_restart_timeout ;
35493536 } else {
35503537 ZCSG (force_restart_time ) = 0 ;
35513538 }
0 commit comments