com php-src: make opcache lockfile path configurable: ext/opcache/README ext/opcache/ZendAccelerator.h ext/opcache/zend_accelerator_ module.c
ext/opcache/zend_shared_alloc.c
| From: | Anatol Belski | Date: | Wed, 06 Apr 2016 11:29:52 +0000 |
| Subject: | com php-src: make opcache lockfile path configurable: ext/opcache/README ext/opcache/ZendAccelerator.h ext/opcache/zend_accelerator_ module.c ext/opcache/zend_shared_alloc.c |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-91633@lists.php.net to get a copy of this message | ||
Commit: d54eafb349975652033bd6705ca1b61eae9aa5ec
Author: Fatih ACAR <fatih.acar@gandi.net> Fri, 4 Mar 2016 11:17:45 +0100
Committer: Anatol Belski <ab@php.net> Wed, 6 Apr 2016 13:29:52 +0200
Parents: 1e1500a2bc30e0f7b0846e16567ffb3728f57eef
Branches: PHP-7.0 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=d54eafb349975652033bd6705ca1b61eae9aa5ec
Log:
make opcache lockfile path configurable
Signed-off-by: William Dauchy <william@gandi.net>
Signed-off-by: Baptiste Daroussin <baptiste.daroussin@gandi.net>
Signed-off-by: Fatih Acar <fatih.acar@gandi.net>
Changed paths:
M ext/opcache/README
M ext/opcache/ZendAccelerator.h
M ext/opcache/zend_accelerator_module.c
M ext/opcache/zend_shared_alloc.c
Diff:
diff --git a/ext/opcache/README b/ext/opcache/README
index c074440..11c9c27 100644
--- a/ext/opcache/README
+++ b/ext/opcache/README
@@ -213,3 +213,6 @@ opcache.mmap_base
processes have to map shared memory into the same address space. This
directive allows to manually fix the "Unable to reattach to base address"
errors.
+
+opcache.lockfile_path (default "/tmp")
+ Absolute path used to store shared lockfiles.
diff --git a/ext/opcache/ZendAccelerator.h b/ext/opcache/ZendAccelerator.h
index 99db6a2..42a34aa 100644
--- a/ext/opcache/ZendAccelerator.h
+++ b/ext/opcache/ZendAccelerator.h
@@ -217,6 +217,7 @@ typedef struct _zend_accel_directives {
zend_long max_file_size;
zend_long interned_strings_buffer;
char *restrict_api;
+ char *lockfile_path;
#ifdef HAVE_OPCACHE_FILE_CACHE
char *file_cache;
zend_bool file_cache_only;
diff --git a/ext/opcache/zend_accelerator_module.c b/ext/opcache/zend_accelerator_module.c
index 2fabc8c..e8c274e 100644
--- a/ext/opcache/zend_accelerator_module.c
+++ b/ext/opcache/zend_accelerator_module.c
@@ -298,6 +298,7 @@ ZEND_INI_BEGIN()
STD_PHP_INI_BOOLEAN("opcache.enable_cli" , "0" , PHP_INI_SYSTEM,
OnUpdateBool, accel_directives.enable_cli, zend_accel_globals,
accel_globals)
STD_PHP_INI_ENTRY("opcache.error_log" , "" , PHP_INI_SYSTEM,
OnUpdateString, accel_directives.error_log, zend_accel_globals,
accel_globals)
STD_PHP_INI_ENTRY("opcache.restrict_api" , "" , PHP_INI_SYSTEM,
OnUpdateString, accel_directives.restrict_api, zend_accel_globals,
accel_globals)
+ STD_PHP_INI_ENTRY("opcache.lockfile_path" , "/tmp" ,
PHP_INI_SYSTEM, OnUpdateString, accel_directives.lockfile_path,
zend_accel_globals, accel_globals)
#ifdef ZEND_WIN32
STD_PHP_INI_ENTRY("opcache.mmap_base", NULL, PHP_INI_SYSTEM, OnUpdateString,
accel_directives.mmap_base, zend_accel_globals, accel_globals)
@@ -710,6 +711,7 @@ static ZEND_FUNCTION(opcache_get_configuration)
add_assoc_bool(&directives, "opcache.fast_shutdown",
ZCG(accel_directives).fast_shutdown);
add_assoc_bool(&directives, "opcache.enable_file_override",
ZCG(accel_directives).file_override_enabled);
add_assoc_long(&directives, "opcache.optimization_level",
ZCG(accel_directives).optimization_level);
+ add_assoc_string(&directives, "opcache.lockfile_path",
STRING_NOT_NULL(ZCG(accel_directives).lockfile_path));
#ifdef HAVE_OPCACHE_FILE_CACHE
add_assoc_string(&directives, "opcache.file_cache",
ZCG(accel_directives).file_cache ? ZCG(accel_directives).file_cache : "");
diff --git a/ext/opcache/zend_shared_alloc.c b/ext/opcache/zend_shared_alloc.c
index 663d905..ff42c4c 100644
--- a/ext/opcache/zend_shared_alloc.c
+++ b/ext/opcache/zend_shared_alloc.c
@@ -38,7 +38,6 @@
# include "sys/mman.h"
#endif
-#define TMP_DIR "/tmp"
#define SEM_FILENAME_PREFIX ".ZendSem."
#define S_H(s) g_shared_alloc_handler->s
@@ -55,7 +54,7 @@ zend_smm_shared_globals *smm_shared_globals;
static MUTEX_T zts_lock;
#endif
int lock_file;
-static char lockfile_name[sizeof(TMP_DIR) + sizeof(SEM_FILENAME_PREFIX) + 8];
+static char lockfile_name[MAXPATHLEN];
#endif
static const zend_shared_memory_handler_entry handler_table[] = {
@@ -75,7 +74,7 @@ static const zend_shared_memory_handler_entry handler_table[] = {
};
#ifndef ZEND_WIN32
-void zend_shared_alloc_create_lock(void)
+void zend_shared_alloc_create_lock(char *lockfile_path)
{
int val;
@@ -83,7 +82,7 @@ void zend_shared_alloc_create_lock(void)
zts_lock = tsrm_mutex_alloc();
#endif
- sprintf(lockfile_name, "%s/%sXXXXXX", TMP_DIR, SEM_FILENAME_PREFIX);
+ snprintf(lockfile_name, sizeof(lockfile_name), "%s/%sXXXXXX", lockfile_path,
SEM_FILENAME_PREFIX);
lock_file = mkstemp(lockfile_name);
fchmod(lock_file, 0666);
@@ -163,7 +162,11 @@ int zend_shared_alloc_startup(size_t requested_size)
smm_shared_globals = &tmp_shared_globals;
ZSMMG(shared_free) = requested_size; /* goes to tmp_shared_globals.shared_free */
+#ifndef ZEND_WIN32
+ zend_shared_alloc_create_lock(ZCG(accel_directives).lockfile_path);
+#else
zend_shared_alloc_create_lock();
+#endif
if (ZCG(accel_directives).memory_model && ZCG(accel_directives).memory_model[0]) {
char *model = ZCG(accel_directives).memory_model;