php_http_persistent_handle_list_t **listp = pp;
zend_hash_apply_with_argument(&(*listp)->free, php_http_persistent_handle_apply_cleanup_ex, rf TSRMLS_CC);
- return (*listp)->used ? ZEND_HASH_APPLY_KEEP : ZEND_HASH_APPLY_REMOVE;
+ if ((*listp)->used) {
+ return ZEND_HASH_APPLY_KEEP;
+ }
+ zend_hash_destroy(&(*listp)->free);
+#if PHP_HTTP_DEBUG_PHANDLES
+ fprintf(stderr, "LSTFREE: %p\n", *listp);
+#endif
+ pefree(*listp, 1);
+ *listp = NULL;
+ return ZEND_HASH_APPLY_REMOVE;
}
static inline void php_http_persistent_handle_list_dtor(php_http_persistent_handle_list_t *list, php_http_persistent_handle_provider_t *provider TSRMLS_DC)
} else {
*handle = php_http_resource_factory_handle_ctor(&provider->rf TSRMLS_CC);
}
-
+#if PHP_HTTP_DEBUG_PHANDLES
+ fprintf(stderr, "CREATED: %p\n", *handle);
+#endif
if (*handle) {
++provider->list.used;
++list->used;
if ((list = php_http_persistent_handle_list_find(provider, ident_str, ident_len TSRMLS_CC))) {
if (provider->list.used >= PHP_HTTP_G->persistent_handle.limit) {
+#if PHP_HTTP_DEBUG_PHANDLES
+ fprintf(stderr, "DESTROY: %p\n", *handle);
+#endif
php_http_resource_factory_handle_dtor(&provider->rf, *handle TSRMLS_CC);
} else {
if (SUCCESS != zend_hash_next_index_insert(&list->free, (void *) handle, sizeof(void *), NULL)) {
{
zend_bool f = a->free_on_abandon;
+#if PHP_HTTP_DEBUG_PHANDLES
+ fprintf(stderr, "ABANDON: %p\n", a->provider);
+#endif
+
STR_FREE(a->ident.str);
memset(a, 0, sizeof(*a));
if (f) {
zend_hash_apply_with_argument(&list->free, php_http_persistent_handle_apply_cleanup_ex, &provider->rf TSRMLS_CC);
}
} else {
- zend_hash_apply_with_argument(&provider->list.free, php_http_persistent_handle_apply_cleanup, &provider->list.free TSRMLS_CC);
+ zend_hash_apply_with_argument(&provider->list.free, php_http_persistent_handle_apply_cleanup, &provider->rf TSRMLS_CC);
}
}
} else {
zend_hash_apply_with_argument(&list->free, php_http_persistent_handle_apply_cleanup_ex, &provider->rf TSRMLS_CC);
}
} else {
- zend_hash_apply_with_argument(&provider->list.free, php_http_persistent_handle_apply_cleanup, &provider->list.free TSRMLS_CC);
+ zend_hash_apply_with_argument(&provider->list.free, php_http_persistent_handle_apply_cleanup, &provider->rf TSRMLS_CC);
}
}
}