| modification, are permitted provided that the conditions mentioned |
| in the accompanying LICENSE file are met. |
+--------------------------------------------------------------------+
- | Copyright (c) 2004-2010, Michael Wallner <mike@php.net> |
+ | Copyright (c) 2004-2011, Michael Wallner <mike@php.net> |
+--------------------------------------------------------------------+
*/
-/* $Id: http_persistent_handle_api.c 292841 2009-12-31 08:48:57Z mike $ */
-
#include "php_http.h"
#ifndef PHP_HTTP_DEBUG_PHANDLES
{
php_http_persistent_handle_list_t **list, *new_list;
- if (SUCCESS == zend_hash_find(&provider->list.free, ident_str, ident_len + 1, (void *) &list)) {
+ if (SUCCESS == zend_symtable_find(&provider->list.free, ident_str, ident_len + 1, (void *) &list)) {
#if PHP_HTTP_DEBUG_PHANDLES
fprintf(stderr, "LSTFIND: %p\n", *list);
#endif
}
if ((new_list = php_http_persistent_handle_list_init(NULL))) {
- if (SUCCESS == zend_hash_add(&provider->list.free, ident_str, ident_len + 1, (void *) &new_list, sizeof(php_http_persistent_handle_list_t *), (void *) &list)) {
+ if (SUCCESS == zend_symtable_update(&provider->list.free, ident_str, ident_len + 1, (void *) &new_list, sizeof(php_http_persistent_handle_list_t *), (void *) &list)) {
#if PHP_HTTP_DEBUG_PHANDLES
fprintf(stderr, "LSTFIND: %p (new)\n", *list);
#endif
php_http_persistent_handle_provider_t *provider = (php_http_persistent_handle_provider_t *) p;
php_http_persistent_handle_list_t **list, *list_tmp;
HashPosition pos;
+ TSRMLS_FETCH();
FOREACH_HASH_VAL(pos, &provider->list.free, list) {
/* fix shutdown crash in PHP4 */
fprintf(stderr, "PROVIDE: %s\n", name_str);
#endif
- if (SUCCESS == zend_hash_add(&php_http_persistent_handles_hash, name_str, name_len+1, (void *) &provider, sizeof(php_http_persistent_handle_provider_t), NULL)) {
+ if (SUCCESS == zend_symtable_update(&php_http_persistent_handles_hash, name_str, name_len+1, (void *) &provider, sizeof(php_http_persistent_handle_provider_t), NULL)) {
status = SUCCESS;
} else {
php_http_resource_factory_dtor(&provider.rf);
memset(a, 0, sizeof(*a));
LOCK();
- status = zend_hash_find(&php_http_persistent_handles_hash, name_str, name_len+1, (void *) &a->provider);
+ status = zend_symtable_find(&php_http_persistent_handles_hash, name_str, name_len+1, (void *) &a->provider);
UNLOCK();
if (SUCCESS == status) {
PHP_HTTP_API void php_http_persistent_handle_release(php_http_persistent_handle_factory_t *a, void *handle TSRMLS_DC)
{
LOCK();
- php_http_persistent_handle_do_release(a->provider, a->ident.str, a->ident.len, &handle);
+ php_http_persistent_handle_do_release(a->provider, a->ident.str, a->ident.len, &handle TSRMLS_CC);
UNLOCK();
}
*handle = NULL;
LOCK();
- if (SUCCESS == zend_hash_find(&php_http_persistent_handles_hash, name_str, name_len+1, (void *) &provider)) {
+ if (SUCCESS == zend_symtable_find(&php_http_persistent_handles_hash, name_str, name_len+1, (void *) &provider)) {
status = php_http_persistent_handle_do_acquire(provider, ident_str, ident_len, handle TSRMLS_CC);
}
UNLOCK();
#endif
LOCK();
- if (SUCCESS == zend_hash_find(&php_http_persistent_handles_hash, name_str, name_len+1, (void *) &provider)) {
+ if (SUCCESS == zend_symtable_find(&php_http_persistent_handles_hash, name_str, name_len+1, (void *) &provider)) {
status = php_http_persistent_handle_do_release(provider, ident_str, ident_len, handle TSRMLS_CC);
}
UNLOCK();
*new_handle = NULL;
LOCK();
- if (SUCCESS == zend_hash_find(&php_http_persistent_handles_hash, name_str, name_len+1, (void *) &provider)) {
+ if (SUCCESS == zend_symtable_find(&php_http_persistent_handles_hash, name_str, name_len+1, (void *) &provider)) {
status = php_http_persistent_handle_do_accrete(provider, ident_str, ident_len, old_handle, new_handle TSRMLS_CC);
}
UNLOCK();
LOCK();
if (name_str && name_len) {
- if (SUCCESS == zend_hash_find(&php_http_persistent_handles_hash, name_str, name_len+1, (void *) &provider)) {
+ if (SUCCESS == zend_symtable_find(&php_http_persistent_handles_hash, name_str, name_len+1, (void *) &provider)) {
if (ident_str && ident_len) {
if ((list = php_http_persistent_handle_list_find(provider, ident_str, ident_len TSRMLS_CC))) {
php_http_persistent_handle_list_dtor(list, provider TSRMLS_CC);
array_init(zentry[1]);
add_assoc_long_ex(zentry[1], ZEND_STRS("used"), (*list)->used);
add_assoc_long_ex(zentry[1], ZEND_STRS("free"), zend_hash_num_elements(&(*list)->free));
-
- /* use zend_hash_* not add_assoc_* (which is zend_symtable_*) as we want a string even for numbers */
- zend_hash_add(Z_ARRVAL_P(zentry[0]), key2.str, key2.len, &zentry[1], sizeof(zval *), NULL);
+ add_assoc_zval_ex(zentry[0], key2.str, key2.len, zentry[1]);
}
- zend_hash_add(ht, key1.str, key1.len, &zentry[0], sizeof(zval *), NULL);
+ zend_symtable_update(ht, key1.str, key1.len, &zentry[0], sizeof(zval *), NULL);
}
} else if (ht) {
ht = NULL;