svn: /pecl/apc/trunk/ apc_bin.c apc_cache.c apc_iterator.c php_apc.c

From: Date: Sun, 08 Aug 2010 21:16:24 +0000
Subject: svn: /pecl/apc/trunk/ apc_bin.c apc_cache.c apc_iterator.c php_apc.c
Groups: php.pecl.cvs 
Request: Send a blank email to pecl-cvs+get-14562@lists.php.net to get a copy of this message
gopalv Sun, 08 Aug 2010 21:16:24 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=302007 Log: Bug #17978: standardize user keys to include NULs in identifier_len. Z_STRLEN_P() doesn't, so add to it. Bug: http://pecl.php.net/bugs/17978 (unknown) Changed paths: U pecl/apc/trunk/apc_bin.c U pecl/apc/trunk/apc_cache.c U pecl/apc/trunk/apc_iterator.c U pecl/apc/trunk/php_apc.c Modified: pecl/apc/trunk/apc_bin.c =================================================================== --- pecl/apc/trunk/apc_bin.c 2010-08-08 21:12:30 UTC (rev 302006) +++ pecl/apc/trunk/apc_bin.c 2010-08-08 21:16:24 UTC (rev 302007) @@ -668,7 +668,7 @@ for(i=0; i < apc_user_cache->num_slots; i++) { sp = apc_user_cache->slots[i]; for(; sp != NULL; sp = sp->next) { - if(apc_bin_checkfilter(user_vars, sp->key.data.user.identifier, sp->key.data.user.identifier_len+1)) { + if(apc_bin_checkfilter(user_vars, sp->key.data.user.identifier, sp->key.data.user.identifier_len)) { size += sizeof(apc_bd_entry_t*) + sizeof(apc_bd_entry_t); size += sp->value->mem_size - (sizeof(apc_cache_entry_t) - sizeof(apc_cache_entry_value_t)); count++; @@ -712,11 +712,11 @@ for(i=0; i < apc_user_cache->num_slots; i++) { sp = apc_user_cache->slots[i]; for(; sp != NULL; sp = sp->next) { - if(apc_bin_checkfilter(user_vars, sp->key.data.user.identifier, sp->key.data.user.identifier_len+1)) { + if(apc_bin_checkfilter(user_vars, sp->key.data.user.identifier, sp->key.data.user.identifier_len)) { ep = &bd->entries[count]; ep->type = sp->value->type; - ep->val.user.info = apc_bd_alloc(sp->value->data.user.info_len + 1 TSRMLS_CC); - memcpy(ep->val.user.info, sp->value->data.user.info, sp->value->data.user.info_len+1); + ep->val.user.info = apc_bd_alloc(sp->value->data.user.info_len TSRMLS_CC); + memcpy(ep->val.user.info, sp->value->data.user.info, sp->value->data.user.info_len); ep->val.user.info_len = sp->value->data.user.info_len; ep->val.user.val = apc_copy_zval(NULL, sp->value->data.user.val, &ctxt TSRMLS_CC); ep->val.user.ttl = sp->value->data.user.ttl; Modified: pecl/apc/trunk/apc_cache.c =================================================================== --- pecl/apc/trunk/apc_cache.c 2010-08-08 21:12:30 UTC (rev 302006) +++ pecl/apc/trunk/apc_cache.c 2010-08-08 21:16:24 UTC (rev 302007) @@ -482,7 +482,7 @@ int apc_cache_user_insert(apc_cache_t* cache, apc_cache_key_t key, apc_cache_entry_t* value, apc_context_t* ctxt, time_t t, int exclusive TSRMLS_DC) { slot_t** slot; - unsigned int keylen = key.data.user.identifier_len+1; + unsigned int keylen = key.data.user.identifier_len; unsigned int h = string_nhash_8(key.data.user.identifier, keylen); apc_keyid_t *lastkey = &cache->header->lastkey; @@ -497,6 +497,7 @@ if(apc_cache_is_last_key(cache, &key, h, t TSRMLS_CC)) { /* potential cache slam */ + printf("Last key warning for it!"); return 0; } @@ -1049,7 +1050,7 @@ entry = (apc_cache_entry_t*) apc_pool_alloc(pool, sizeof(apc_cache_entry_t)); if (!entry) return NULL; - entry->data.user.info = apc_pmemcpy(info, (info_len + 1), pool TSRMLS_CC); + entry->data.user.info = apc_pmemcpy(info, info_len, pool TSRMLS_CC); entry->data.user.info_len = info_len; if(!entry->data.user.info) { return NULL; @@ -1232,7 +1233,7 @@ zend_bool apc_cache_is_last_key(apc_cache_t* cache, apc_cache_key_t* key, unsigned int h, time_t t TSRMLS_DC) { apc_keyid_t *lastkey = &cache->header->lastkey; - unsigned int keylen = key->data.user.identifier_len+1; + unsigned int keylen = key->data.user.identifier_len; if(!h) h = string_nhash_8(key->data.user.identifier, keylen); Modified: pecl/apc/trunk/apc_iterator.c =================================================================== --- pecl/apc/trunk/apc_iterator.c 2010-08-08 21:12:30 UTC (rev 302006) +++ pecl/apc/trunk/apc_iterator.c 2010-08-08 21:16:24 UTC (rev 302007) @@ -102,7 +102,7 @@ } } if (APC_ITER_KEY & iterator->format) { - add_assoc_stringl(item->value, "key", item->key, item->key_len, 1); + add_assoc_stringl(item->value, "key", item->key, (item->key_len - 1), 1); } if (APC_ITER_VALUE & iterator->format) { if(slot->value->type == APC_CACHE_ENTRY_USER) { @@ -255,7 +255,7 @@ #endif if (iterator->search_hash) { - rval = zend_hash_exists(iterator->search_hash, key, key_len+1); + rval = zend_hash_exists(iterator->search_hash, key, key_len); if (!rval && fname_key) { rval = zend_hash_exists(iterator->search_hash, fname_key, fname_key_len+1); } @@ -510,7 +510,7 @@ item = apc_stack_get(iterator->stack, iterator->stack_idx); if (item->key) { - RETURN_STRINGL(item->key, item->key_len, 1); + RETURN_STRINGL(item->key, (item->key_len-1), 1); } else { RETURN_LONG(iterator->key_idx); } @@ -691,7 +691,7 @@ if (iterator->cache == apc_cache) { apc_cache_delete(apc_cache, item->filename_key, strlen(item->filename_key) + 1 TSRMLS_CC); } else { - apc_cache_user_delete(apc_user_cache, item->key, (item->key_len + 1) TSRMLS_CC); + apc_cache_user_delete(apc_user_cache, item->key, item->key_len TSRMLS_CC); } } } Modified: pecl/apc/trunk/php_apc.c =================================================================== --- pecl/apc/trunk/php_apc.c 2010-08-08 21:12:30 UTC (rev 302006) +++ pecl/apc/trunk/php_apc.c 2010-08-08 21:16:24 UTC (rev 302007) @@ -755,8 +755,7 @@ while(zend_hash_get_current_data_ex(hash, (void**)&hentry, &hpos) == SUCCESS) { zend_hash_get_current_key_ex(hash, &hkey, &hkey_len, &hkey_idx, 0, &hpos); if (hkey) { - /* hkey_len - 1 for consistency, because it includes '\0', while Z_STRLEN_P() doesn't */ - if(!_apc_store(hkey, hkey_len - 1, *hentry, (unsigned int)ttl, exclusive TSRMLS_CC)) { + if(!_apc_store(hkey, hkey_len, *hentry, (unsigned int)ttl, exclusive TSRMLS_CC)) { add_assoc_long_ex(return_value, hkey, hkey_len, -1); /* -1: insertion error */ } hkey = NULL; @@ -768,7 +767,7 @@ return; } else if (Z_TYPE_P(key) == IS_STRING) { if (!val) RETURN_FALSE; - if(_apc_store(Z_STRVAL_P(key), Z_STRLEN_P(key), val, (unsigned int)ttl, exclusive TSRMLS_CC)) + if(_apc_store(Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, val, (unsigned int)ttl, exclusive TSRMLS_CC)) RETURN_TRUE; } else { apc_wprint("apc_store expects key parameter to be a string or an array of key/value pairs."); @@ -1209,7 +1208,7 @@ if(!strkey_len) RETURN_FALSE; _apc_define_constants(constants, case_sensitive TSRMLS_CC); - if(_apc_store(strkey, strkey_len, constants, 0, 0 TSRMLS_CC)) RETURN_TRUE; + if(_apc_store(strkey, strkey_len + 1, constants, 0, 0 TSRMLS_CC)) RETURN_TRUE; RETURN_FALSE; } /* }}} */

« previous php.pecl.cvs (#14562) next »