Skip to content

Commit a7e036b

Browse files
committed
Use time() as a fallback when gettimeofday() is not available for opcache CLI revalidation
1 parent ca2c359 commit a7e036b

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

ext/opcache/ZendAccelerator.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,14 +1165,19 @@ zend_result validate_timestamp_and_record(zend_persistent_script *persistent_scr
11651165
}
11661166

11671167
if (ZCG(cli_mode)) {
1168+
// check current time as opposed to the "time of request"
1169+
double now = 0.0;
1170+
#ifdef HAVE_GETTIMEOFDAY
11681171
struct timeval tp = {0};
11691172

1170-
//check current time as opposed to the "time of request"
1171-
if (gettimeofday(&tp, NULL) != 0) {
1172-
return SUCCESS;
1173+
if (UNEXPECTED(gettimeofday(&tp, NULL) != 0)) {
1174+
now = (double)time(NULL);
1175+
} else {
1176+
now = (double)(tp.tv_sec + tp.tv_usec / 1000000.00);
11731177
}
1174-
1175-
double now = (double)(tp.tv_sec + tp.tv_usec / 1000000.00);
1178+
#else
1179+
now = (double)time(NULL);
1180+
#endif
11761181

11771182
if (ZCG(accel_directives).revalidate_freq && persistent_script->dynamic_members.revalidate >= now) {
11781183
return SUCCESS;

0 commit comments

Comments
 (0)