#include "ext/standard/info.h"
#include "php_raphf.h"
+#ifndef PHP_RAPHF_TEST
+# define PHP_RAPHF_TEST 0
+#endif
+
struct php_persistent_handle_globals {
ulong limit;
HashTable hash;
zval zsubentry, *zentry = va_arg(argv, zval *);
array_init(&zsubentry);
- add_assoc_long_ex(&zsubentry, ZEND_STRS("used"), list->used);
- add_assoc_long_ex(&zsubentry, ZEND_STRS("free"),
+ add_assoc_long_ex(&zsubentry, ZEND_STRL("used"), list->used);
+ add_assoc_long_ex(&zsubentry, ZEND_STRL("free"),
zend_hash_num_elements(&list->free));
- add_assoc_zval_ex(zentry, key->key->val, key->key->len, &zsubentry);
-
+ if (key->key) {
+ add_assoc_zval_ex(zentry, key->key->val, key->key->len, &zsubentry);
+ } else {
+ add_index_zval(zentry, key->h, &zsubentry);
+ }
return ZEND_HASH_APPLY_KEEP;
}
zend_hash_apply_with_arguments(&provider->list.free TSRMLS_CC,
php_persistent_handle_apply_stat, 1, &zentry);
- zend_symtable_update(ht, key->key, &zentry);
+
+ if (key->key) {
+ zend_hash_update(ht, key->key, &zentry);
+ } else {
+ zend_hash_index_update(ht, key->h, &zentry);
+ }
return ZEND_HASH_APPLY_KEEP;
}
{
php_persistent_handle_list_t *list;
- list = zend_symtable_str_find_ptr(&provider->list.free, ident_str,
- ident_len + 1);
+ list = zend_symtable_str_find_ptr(&provider->list.free, ident_str, ident_len);
if (list) {
#if PHP_RAPHF_DEBUG_PHANDLES
return FAILURE;
}
+
php_persistent_handle_factory_t *php_persistent_handle_concede(
php_persistent_handle_factory_t *a, const char *name_str,
size_t name_len, const char *ident_str, size_t ident_len,
memset(a, 0, sizeof(*a));
a->provider = zend_symtable_str_find_ptr(&PHP_RAPHF_G->persistent_handle.hash,
- name_str, name_len+1);
+ name_str, name_len);
if (a->provider) {
a->ident.str = estrndup(ident_str, ident_len);
if (name_str && name_len) {
provider = zend_symtable_str_find_ptr(&PHP_RAPHF_G->persistent_handle.hash,
- name_str, name_len+1);
+ name_str, name_len);
if (provider) {
if (ident_str && ident_len) {
}
}
+#if PHP_RAPHF_TEST
+# include "php_raphf_test.c"
+#endif
+
static const zend_function_entry raphf_functions[] = {
ZEND_NS_FENTRY("raphf", stat_persistent_handles,
ZEND_FN(raphf_stat_persistent_handles),
ZEND_NS_FENTRY("raphf", clean_persistent_handles,
ZEND_FN(raphf_clean_persistent_handles),
ai_raphf_clean_persistent_handles, 0)
+#if PHP_RAPHF_TEST
+ ZEND_NS_FENTRY("raphf", provide, ZEND_FN(raphf_provide), NULL, 0)
+ ZEND_NS_FENTRY("raphf", conceal, ZEND_FN(raphf_conceal), NULL, 0)
+ ZEND_NS_FENTRY("raphf", concede, ZEND_FN(raphf_concede), NULL, 0)
+ ZEND_NS_FENTRY("raphf", dispute, ZEND_FN(raphf_dispute), NULL, 0)
+ ZEND_NS_FENTRY("raphf", handle_ctor, ZEND_FN(raphf_handle_ctor), NULL, 0)
+ ZEND_NS_FENTRY("raphf", handle_copy, ZEND_FN(raphf_handle_copy), NULL, 0)
+ ZEND_NS_FENTRY("raphf", handle_dtor, ZEND_FN(raphf_handle_dtor), NULL, 0)
+#endif
{0}
};
PHP_MINIT_FUNCTION(raphf)
{
php_persistent_handles_global_hash = &PHP_RAPHF_G->persistent_handle.hash;
+
+#if PHP_RAPHF_TEST
+ PHP_MINIT(raphf_test)(INIT_FUNC_ARGS_PASSTHRU);
+#endif
+
REGISTER_INI_ENTRIES();
return SUCCESS;
}
PHP_MSHUTDOWN_FUNCTION(raphf)
{
+#if PHP_RAPHF_TEST
+ PHP_MSHUTDOWN(raphf_test)(SHUTDOWN_FUNC_ARGS_PASSTHRU);
+#endif
+
UNREGISTER_INI_ENTRIES();
php_persistent_handles_global_hash = NULL;
return SUCCESS;
ZEND_GET_MODULE(raphf)
#endif
-
/*
* Local variables:
* tab-width: 4