Patch apc-3.1.13-fix-warnings.diff for APC Bug #58982
Patch version 2013-01-09 11:51 UTC
Return to Bug #58982 |
Download this patch
Patch Revisions:
Developer: hanno@hboeck.de
diff -Naur APC-3.1.13/apc_bin.c APC-3.1.13-fix-warnings/apc_bin.c
--- APC-3.1.13/apc_bin.c 2012-09-03 18:52:51.000000000 +0200
+++ APC-3.1.13-fix-warnings/apc_bin.c 2013-01-09 12:40:30.906380305 +0100
@@ -719,7 +719,7 @@
apc_bd_alloc_ex(pool_ptr, sizeof(apc_pool) TSRMLS_CC);
ctxt.pool = apc_pool_create(APC_UNPOOL, apc_bd_alloc, apc_bd_free, NULL, NULL TSRMLS_CC); /* ideally the pool wouldn't be alloc'd as part of this */
if (!ctxt.pool) { /* TODO need to cleanup */
- apc_warning("Unable to allocate memory for pool." TSRMLS_CC);
+ php_log_err("Unable to allocate memory for pool." TSRMLS_CC);
return NULL;
}
ctxt.copy = APC_COPY_IN_OPCODE; /* avoid stupid ALLOC_ZVAL calls here, hack */
@@ -894,7 +894,7 @@
for(i = 0; i < bd->num_entries; i++) {
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) { /* TODO need to cleanup previous pools */
- apc_warning("Unable to allocate memory for pool." TSRMLS_CC);
+ php_log_err("Unable to allocate memory for pool." TSRMLS_CC);
goto failure;
}
ep = &bd->entries[i];
diff -Naur APC-3.1.13/apc_cache.c APC-3.1.13-fix-warnings/apc_cache.c
--- APC-3.1.13/apc_cache.c 2012-09-03 18:52:51.000000000 +0200
+++ APC-3.1.13-fix-warnings/apc_cache.c 2013-01-09 12:42:24.598958952 +0100
@@ -1334,6 +1334,7 @@
/* {{{ apc_cache_is_last_key */
zend_bool apc_cache_is_last_key(apc_cache_t* cache, apc_cache_key_t* key, time_t t TSRMLS_DC)
{
+ char *log_message;
apc_keyid_t *lastkey = &cache->header->lastkey;
unsigned int keylen = key->data.user.identifier_len;
#ifdef ZTS
@@ -1350,7 +1351,10 @@
if(lastkey->mtime == t && FROM_DIFFERENT_THREAD(lastkey)) {
/* potential cache slam */
if(APCG(slam_defense)) {
- apc_debug("Potential cache slam averted for key '%s'" TSRMLS_CC, key->data.user.identifier);
+ log_message = emalloc((key->data.user.identifier_len + 40) * sizeof(char));
+ sprintf(log_message, "Potential cache slam averted for key '%s'", key->data.user.identifier);
+ php_log_err(log_message TSRMLS_CC);
+ efree(log_message);
return 1;
}
}
diff -Naur APC-3.1.13/apc_main.c APC-3.1.13-fix-warnings/apc_main.c
--- APC-3.1.13/apc_main.c 2012-09-03 18:52:51.000000000 +0200
+++ APC-3.1.13-fix-warnings/apc_main.c 2013-01-09 12:40:30.909380268 +0100
@@ -403,7 +403,7 @@
ctxt.pool = apc_pool_create(APC_MEDIUM_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);
+ php_log_err("Unable to allocate memory for pool." TSRMLS_CC);
return FAILURE;
}
ctxt.copy = APC_COPY_IN_OPCODE;
@@ -528,7 +528,7 @@
ctxt.pool = apc_pool_create(APC_UNPOOL, apc_php_malloc, apc_php_free,
apc_sma_protect, apc_sma_unprotect TSRMLS_CC);
if (!ctxt.pool) {
- apc_warning("Unable to allocate memory for pool." TSRMLS_CC);
+ php_log_err("Unable to allocate memory for pool." TSRMLS_CC);
return old_compile_file(h, type TSRMLS_CC);
}
ctxt.copy = APC_COPY_OUT_OPCODE;
diff -Naur APC-3.1.13/php_apc.c APC-3.1.13-fix-warnings/php_apc.c
--- APC-3.1.13/php_apc.c 2012-09-03 18:52:51.000000000 +0200
+++ APC-3.1.13-fix-warnings/php_apc.c 2013-01-09 12:41:06.435936125 +0100
@@ -589,7 +589,7 @@
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) {
HANDLE_UNBLOCK_INTERRUPTIONS();
- apc_warning("Unable to allocate memory for pool." TSRMLS_CC);
+ php_log_err("Unable to allocate memory for pool." TSRMLS_CC);
return 0;
}
ctxt.copy = APC_COPY_IN_USER;
@@ -838,7 +838,7 @@
ctxt.pool = apc_pool_create(APC_UNPOOL, apc_php_malloc, apc_php_free, NULL, NULL TSRMLS_CC);
if (!ctxt.pool) {
- apc_warning("Unable to allocate memory for pool." TSRMLS_CC);
+ php_log_err("Unable to allocate memory for pool." TSRMLS_CC);
RETURN_FALSE;
}
ctxt.copy = APC_COPY_OUT_USER;
|