com php-src: "locked" must be a "module" global (local to thread): ZendAccelerator.h zend_shared_alloc.c
| From: | Dmitry Stogov | Date: | Fri, 15 Feb 2013 13:35:58 +0000 |
| Subject: | com php-src: "locked" must be a "module" global (local to thread): ZendAccelerator.h zend_shared_alloc.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-71539@lists.php.net to get a copy of this message | ||
Commit: 4c97b6c8cf7e9ff56be6511c9e4f40af1562b835
Author: Dmitry Stogov <dmitry@zend.com> Fri, 15 Feb 2013 17:35:58 +0400
Parents: d70ed26aaac1d3f613026f61d115a0ce05190315
Branches: PHP-5.5 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=4c97b6c8cf7e9ff56be6511c9e4f40af1562b835
Log:
"locked" must be a "module" global (local to thread)
Changed paths:
M ZendAccelerator.h
M zend_shared_alloc.c
Diff:
diff --git a/ZendAccelerator.h b/ZendAccelerator.h
index 918e48f..36f1b54 100644
--- a/ZendAccelerator.h
+++ b/ZendAccelerator.h
@@ -231,6 +231,7 @@ typedef struct _zend_accel_globals {
int internal_functions_count;
int counted; /* the process uses shatred memory */
zend_bool enabled;
+ zend_bool locked; /* thread obtained exclusive lock */
HashTable bind_hash; /* prototype and zval lookup table */
zend_accel_directives accel_directives;
char *cwd; /* current working directory or NULL */
diff --git a/zend_shared_alloc.c b/zend_shared_alloc..c
index 12bfef2..c4e0e55 100644
--- a/zend_shared_alloc.c
+++ b/zend_shared_alloc.c
@@ -43,7 +43,6 @@
#define S_H(s) g_shared_alloc_handler->s
/* True globals */
-static zend_bool locked;
/* old/new mapping. We can use true global even for ZTS because its usage
is wrapped with exclusive lock anyway */
static HashTable xlat_table;
@@ -214,7 +213,7 @@ int zend_shared_alloc_startup(int requested_size)
shared_segments_array_size = ZSMMG(shared_segments_count)*S_H(segment_type_size)();
/* move shared_segments and shared_free to shared memory */
- locked = 1; /* no need to perform a real lock at this point */
+ ZCG(locked) = 1; /* no need to perform a real lock at this point */
p_tmp_shared_globals = (zend_smm_shared_globals *)
zend_shared_alloc(sizeof(zend_smm_shared_globals));
tmp_shared_segments =
zend_shared_alloc(shared_segments_array_size+ZSMMG(shared_segments_count)*sizeof(void *));
@@ -227,7 +226,7 @@ int zend_shared_alloc_startup(int requested_size)
ZSMMG(shared_segments) = tmp_shared_segments;
ZSMMG(shared_memory_state).positions = (int *)
zend_shared_alloc(sizeof(int)*ZSMMG(shared_segments_count));
- locked = 0;
+ ZCG(locked) = 0;
return res;
}
@@ -255,7 +254,6 @@ void zend_shared_alloc_shutdown(void)
#ifndef ZEND_WIN32
close(lock_file);
#endif
- locked = 0;
}
#define SHARED_ALLOC_FAILED() { \
@@ -270,9 +268,10 @@ void *zend_shared_alloc(size_t size)
{
int i;
unsigned int block_size = size+sizeof(zend_shared_memory_block_header);
+ TSRMLS_FETCH();
#if 1
- if (!locked) {
+ if (!ZCG(locked)) {
zend_accel_error(ACCEL_LOG_ERROR, "Shared memory lock not obtained");
}
#endif
@@ -334,7 +333,7 @@ void *_zend_shared_memdup(void *source, size_t size, zend_bool free_source TSRML
void zend_shared_alloc_safe_unlock(TSRMLS_D)
{
- if (locked) {
+ if (ZCG(locked)) {
zend_shared_alloc_unlock(TSRMLS_C);
}
}
@@ -373,7 +372,7 @@ void zend_shared_alloc_lock(TSRMLS_D)
zend_shared_alloc_lock_win32();
#endif
- locked=1;
+ ZCG(locked) = 1;
/* Prepare translation table
*
@@ -389,7 +388,7 @@ void zend_shared_alloc_unlock(TSRMLS_D)
/* Destroy translation table */
zend_hash_destroy(&xlat_table);
- locked=0;
+ ZCG(locked) = 0;
#ifndef ZEND_WIN32
if (fcntl(lock_file, F_SETLK, &mem_write_unlock) == -1) {