cvs: pecl /apc apc.php apc_cache.c php_apc.c
| From: | Rasmus Lerdorf | Date: | Sun, 12 Sep 2004 06:12:17 +0000 |
| Subject: | cvs: pecl /apc apc.php apc_cache.c php_apc.c | ||
| Groups: | php.pecl.cvs | ||
| Request: | Send a blank email to pecl-cvs+get-1820@lists.php.net to get a copy of this message | ||
rasmus Sun Sep 12 02:12:17 2004 EDT
Added files:
/pecl/apc apc.php
Modified files:
/pecl/apc apc_cache.c php_apc.c
Log:
Get rid of apc_clear_user_cache function. Added an optional arg to
apc_clear_cache() instead.
Removed some debug
Added apc.php status page script. It's like phpinfo() for APC.
http://cvs.php.net/diff.php/pecl/apc/apc_cache.c?r1=3.67&r2=3.68&ty=u
Index: pecl/apc/apc_cache.c
diff -u pecl/apc/apc_cache.c:3.67 pecl/apc/apc_cache.c:3.68
--- pecl/apc/apc_cache.c:3.67 Sat Sep 11 22:56:58 2004
+++ pecl/apc/apc_cache.c Sun Sep 12 02:12:17 2004
@@ -15,7 +15,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: apc_cache.c,v 3.67 2004/09/12 02:56:58 rasmus Exp $ */
+/* $Id: apc_cache.c,v 3.68 2004/09/12 06:12:17 rasmus Exp $ */
#include "apc_cache.h"
#include "apc_lock.h"
@@ -323,8 +323,6 @@
return 0;
}
- printf("apc_cache_insert called for key at 0x%lx and value at 0x%lx\n",key,value);
-
LOCK(cache);
process_pending_removals(cache);
@@ -426,7 +424,6 @@
cache->header->num_hits++;
UNLOCK(cache);
- printf("apc_cache_find: found entry at 0x%lx\n",(*slot)->value);
return (*slot)->value;
}
slot = &(*slot)->next;
@@ -568,7 +565,6 @@
entry = (apc_cache_entry_t*) apc_sma_malloc(sizeof(apc_cache_entry_t));
if (!entry) return NULL;
- printf("Made new file entry at 0x%lx\n",entry);
entry->data.file.filename = apc_xstrdup(filename, apc_sma_malloc);
if(!entry->data.file.filename) {
@@ -591,7 +587,6 @@
entry = (apc_cache_entry_t*) apc_sma_malloc(sizeof(apc_cache_entry_t));
if (!entry) return NULL;
- printf("Made new user entry at 0x%lx\n",entry);
entry->data.user.info = apc_xstrdup(info, apc_sma_malloc);
if(!entry->data.user.info) {
@@ -645,6 +640,10 @@
LOCK(cache);
info = (apc_cache_info_t*) apc_emalloc(sizeof(apc_cache_info_t));
+ if(!info) {
+ UNLOCK(cache);
+ return NULL;
+ }
info->num_slots = cache->num_slots;
info->ttl = cache->ttl;
info->num_hits = cache->header->num_hits;
@@ -656,8 +655,7 @@
for (i = 0; i < info->num_slots; i++) {
p = cache->slots[i];
for (; p != NULL; p = p->next) {
- apc_cache_link_t* link = (apc_cache_link_t*)
- apc_emalloc(sizeof(apc_cache_link_t));
+ apc_cache_link_t* link = (apc_cache_link_t*) apc_emalloc(sizeof(apc_cache_link_t));
if(p->value->type == APC_CACHE_ENTRY_FILE) {
link->data.file.filename = apc_xstrdup(p->value->data.file.filename,
apc_emalloc);
http://cvs.php.net/diff.php/pecl/apc/php_apc.c?r1=3.34&r2=3.35&ty=u
Index: pecl/apc/php_apc.c
diff -u pecl/apc/php_apc.c:3.34 pecl/apc/php_apc.c:3.35
--- pecl/apc/php_apc.c:3.34 Sat Sep 11 22:56:58 2004
+++ pecl/apc/php_apc.c Sun Sep 12 02:12:17 2004
@@ -14,7 +14,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_apc.c,v 3.34 2004/09/12 02:56:58 rasmus Exp $ */
+/* $Id: php_apc.c,v 3.35 2004/09/12 06:12:17 rasmus Exp $ */
#ifdef PHP_WIN32
/* XXX lame hack, for some reason, the ini entries are all messed
@@ -121,7 +121,7 @@
#else
php_info_print_table_row(2, "MMAP Support", "Disabled");
#endif
- php_info_print_table_row(2, "Revision", "$Revision: 3.34 $");
+ php_info_print_table_row(2, "Revision", "$Revision: 3.35 $");
php_info_print_table_row(2, "Build Date", __DATE__ " " __TIME__);
DISPLAY_INI_ENTRIES();
php_info_print_table_end();
@@ -180,18 +180,20 @@
char *cache_type;
int ct_len;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &cache_type, &ct_len) ==
FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s", &cache_type, &ct_len) ==
FAILURE) {
return;
}
- if(!strcasecmp(cache_type,"opcode")) {
- info = apc_cache_info(APCG(cache));
- } else if(!strcasecmp(cache_type,"user")) {
- info = apc_cache_info(APCG(user_cache));
- }
+ if(ZEND_NUM_ARGS()) {
+ if(!strcasecmp(cache_type,"user")) {
+ info = apc_cache_info(APCG(user_cache));
+ } else {
+ info = apc_cache_info(APCG(cache));
+ }
+ } else info = apc_cache_info(APCG(cache));
if(!info) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "No APC info available. Perhaps APC is
disabled via apc.enabled?");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "No APC info available. Perhaps APC is
not enabled? Check apc.enabled in your ini file");
RETURN_FALSE;
}
@@ -265,20 +267,20 @@
/* {{{ proto void apc_clear_cache() */
PHP_FUNCTION(apc_clear_cache)
{
- if (ZEND_NUM_ARGS() != 0) {
- WRONG_PARAM_COUNT;
- }
- apc_cache_clear(APCG(cache));
-}
-/* }}} */
+ char *cache_type;
+ int ct_len;
-/* {{{ proto void apc_clear_user_cache() */
-PHP_FUNCTION(apc_clear_user_cache)
-{
- if (ZEND_NUM_ARGS() != 0) {
- WRONG_PARAM_COUNT;
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s", &cache_type, &ct_len) ==
FAILURE) {
+ return;
+ }
+
+ if(ZEND_NUM_ARGS()) {
+ if(!strcasecmp(cache_type,"user")) {
+ apc_cache_clear(APCG(user_cache));
+ RETURN_TRUE;
+ }
}
- apc_cache_clear(APCG(user_cache));
+ apc_cache_clear(APCG(cache));
}
/* }}} */
@@ -352,8 +354,6 @@
RETURN_FALSE;
}
- printf("apc_store: user entry at 0x%lx\n",entry);
-
if (!apc_cache_make_user_key(&key, strkey TSRMLS_CC)) {
apc_cache_free_entry(entry);
RETURN_FALSE;
@@ -405,9 +405,7 @@
/* deep-copy returned shm zval to emalloc'ed return_value */
memcpy(return_value, entry->data.user.val, sizeof(zval));
zval_copy_ctor(return_value);
- printf("apc_fetch: entry found at 0x%lx\n",entry);
} else {
- printf("apc_cache_user_find returned NULL\n");
RETURN_FALSE;
}
}
@@ -444,7 +442,6 @@
function_entry apc_functions[] = {
PHP_FE(apc_cache_info, NULL)
PHP_FE(apc_clear_cache, NULL)
- PHP_FE(apc_clear_user_cache, NULL)
PHP_FE(apc_sma_info, NULL)
PHP_FE(apc_store, NULL)
PHP_FE(apc_fetch, NULL)
http://cvs.php.net/co.php/pecl/apc/apc.php?r=1.1&p=1
Index: pecl/apc/apc.php
+++ pecl/apc/apc.php