Patch APC-3.1.9-bailout_deadlock.patch for APC Bug #59281
Patch version 2012-07-03 17:58 UTC
Return to Bug #59281 |
Download this patch
Patch Revisions:
Developer: askalski@gmail.com
diff --git a/apc_main.c b/apc_main.c
index be365df..da67407 100644
--- a/apc_main.c
+++ b/apc_main.c
@@ -406,7 +406,9 @@ zend_bool apc_compile_cache_entry(apc_cache_key_t key, zend_file_handle* h, int
/* compile the file using the default compile function, *
* we set *op_array here so we return opcodes during *
* a failure. We should not return prior to this line. */
+ HANDLE_UNBLOCK_INTERRUPTIONS();
*op_array = old_compile_file(h, type TSRMLS_CC);
+ HANDLE_BLOCK_INTERRUPTIONS();
if (*op_array == NULL) {
return FAILURE;
}
@@ -490,6 +492,7 @@ static zend_op_array* my_compile_file(zend_file_handle* h,
time_t t;
apc_context_t ctxt = {0,};
int bailout=0;
+ int blocking_interruptions;
const char* filename = NULL;
if (!APCG(enabled) || apc_cache_busy(apc_cache)) {
@@ -596,6 +599,7 @@ static zend_op_array* my_compile_file(zend_file_handle* h,
}
HANDLE_BLOCK_INTERRUPTIONS();
+ blocking_interruptions = EG(blocking_interruptions);
#if NONBLOCKING_LOCK_AVAILABLE
if(APCG(write_lock)) {
@@ -626,7 +630,10 @@ static zend_op_array* my_compile_file(zend_file_handle* h,
apc_cache_write_unlock(apc_cache TSRMLS_CC);
}
#endif
- HANDLE_UNBLOCK_INTERRUPTIONS();
+ /* Interruptions won't be re-blocked on parse error, so check first */
+ if (blocking_interruptions == EG(blocking_interruptions)) {
+ HANDLE_UNBLOCK_INTERRUPTIONS();
+ }
if (bailout) zend_bailout();
diff --git a/php_apc.c b/php_apc.c
index 767b548..410d5d5 100644
--- a/php_apc.c
+++ b/php_apc.c
@@ -589,6 +589,7 @@ int _apc_store(char *strkey, int strkey_len, const zval *val, const unsigned int
ctxt.pool = apc_pool_create(APC_SMALL_POOL, apc_sma_malloc, apc_sma_free, apc_sma_protect, apc_sma_unprotect TSRMLS_CC);
if (!ctxt.pool) {
apc_warning("Unable to allocate memory for pool." TSRMLS_CC);
+ HANDLE_UNBLOCK_INTERRUPTIONS();
return 0;
}
ctxt.copy = APC_COPY_IN_USER;
@@ -1164,6 +1165,7 @@ PHP_FUNCTION(apc_compile_file) {
apc_context_t ctxt = {0,};
zend_execute_data *orig_current_execute_data;
int atomic_fail;
+ int blocking_interruptions;
if(!APCG(enabled)) RETURN_FALSE;
@@ -1177,6 +1179,7 @@ PHP_FUNCTION(apc_compile_file) {
}
HANDLE_BLOCK_INTERRUPTIONS();
+ blocking_interruptions = EG(blocking_interruptions);
APCG(current_cache) = apc_cache;
/* reset filters and cache_by_default */
@@ -1345,7 +1348,10 @@ PHP_FUNCTION(apc_compile_file) {
APCG(cache_by_default) = cache_by_default;
APCG(current_cache) = NULL;
- HANDLE_UNBLOCK_INTERRUPTIONS();
+ /* Interruptions won't be re-blocked on parse error, so check first */
+ if (blocking_interruptions == EG(blocking_interruptions)) {
+ HANDLE_UNBLOCK_INTERRUPTIONS();
+ }
}
/* }}} */
|