-
Notifications
You must be signed in to change notification settings - Fork 7.9k
opcache: support file_cache_read_only (php#16484) #16551
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
2e614ae
c32b7ea
9c42cd1
79dd38e
1197a96
86e5178
3397f29
8c43a77
8aaa51d
3e1c63b
9510786
c45c69e
e5526bd
112b9d6
62765b7
35bca09
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -1411,6 +1411,9 @@ zend_result zend_accel_invalidate(zend_string *filename, bool force) | |||||
} | ||||||
|
||||||
if (ZCG(accel_directives).file_cache) { | ||||||
if (ZCG(accel_directives).file_cache_read_only) { | ||||||
return FAILURE; | ||||||
} | ||||||
zend_file_cache_invalidate(realpath); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should skip |
||||||
} | ||||||
|
||||||
|
@@ -3300,6 +3303,50 @@ static zend_result accel_post_startup(void) | |||||
#endif | ||||||
accel_shared_globals = calloc(1, sizeof(zend_accel_shared_globals)); | ||||||
} | ||||||
|
||||||
/* opcache.file_cache_read_only should only be enabled when all script files are read-only */ | ||||||
int file_cache_access_mode = 0; | ||||||
|
||||||
if (ZCG(accel_directives).file_cache_read_only) { | ||||||
if (!ZCG(accel_directives).file_cache) { | ||||||
accel_startup_ok = false; | ||||||
zend_accel_error_noreturn(ACCEL_LOG_FATAL, "opcache.file_cache_read_only is set without a proper setting of opcache.file_cache"); | ||||||
return SUCCESS; | ||||||
} | ||||||
|
||||||
/* opcache.file_cache is read only, so ensure the directory is readable */ | ||||||
#ifndef ZEND_WIN32 | ||||||
file_cache_access_mode = R_OK | X_OK; | ||||||
#else | ||||||
file_cache_access_mode = 04; // Read access | ||||||
#endif | ||||||
} else { | ||||||
/* opcache.file_cache isn't read only, so ensure the directory is writable */ | ||||||
#ifndef ZEND_WIN32 | ||||||
file_cache_access_mode = R_OK | W_OK | X_OK; | ||||||
#else | ||||||
file_cache_access_mode = 06; // Read and write access | ||||||
#endif | ||||||
} | ||||||
|
||||||
if ( ZCG(accel_directives).file_cache ){ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: code style
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, I guess ‘go fmt’ has made me a bit lazy with manual formatting - thanks for pointing this out! |
||||||
zend_stat_t buf = {0}; | ||||||
|
||||||
if (!IS_ABSOLUTE_PATH(ZCG(accel_directives).file_cache, strlen(ZCG(accel_directives).file_cache)) || | ||||||
zend_stat(ZCG(accel_directives).file_cache, &buf) != 0 || | ||||||
!S_ISDIR(buf.st_mode) || | ||||||
#ifndef ZEND_WIN32 | ||||||
access(ZCG(accel_directives).file_cache, file_cache_access_mode) != 0 | ||||||
#else | ||||||
_access(ZCG(accel_directives).file_cache, file_cache_access_mode) != 0 | ||||||
#endif | ||||||
) { | ||||||
accel_startup_ok = false; | ||||||
zend_accel_error_noreturn(ACCEL_LOG_FATAL, "opcache.file_cache must be a full path of an accessible directory"); | ||||||
return SUCCESS; | ||||||
} | ||||||
} | ||||||
|
||||||
#if ENABLE_FILE_CACHE_FALLBACK | ||||||
file_cache_fallback: | ||||||
#endif | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
realpath
must be released here