split off raphf
authorMichael Wallner <mike@php.net>
Sun, 3 Feb 2013 21:51:56 +0000 (21:51 +0000)
committerMichael Wallner <mike@php.net>
Sun, 3 Feb 2013 21:51:56 +0000 (21:51 +0000)
21 files changed:
config9.m4
php_http.c
php_http_api.h
php_http_client.c
php_http_client.h
php_http_client_datashare.c
php_http_client_datashare.h
php_http_client_factory.c
php_http_client_pool.c
php_http_client_pool.h
php_http_curl_client.c
php_http_curl_client_datashare.c
php_http_curl_client_pool.c
php_http_env.c
php_http_env.h
php_http_persistent_handle.c [deleted file]
php_http_persistent_handle.h [deleted file]
php_http_resource_factory.c [deleted file]
php_http_resource_factory.h [deleted file]
tests/persistenthandles001.phpt [deleted file]
tests/phpunit.phpt

index 2979106..00ff2aa 100644 (file)
@@ -363,6 +363,32 @@ dnl ----
                ])
        fi
 
+dnl ----
+dnl RAPHF
+dnl ----
+       HTTP_HAVE_PHP_EXT([raphf], [
+               AC_MSG_CHECKING([for php_raphf.h])
+               HTTP_EXT_RAPHF_INCDIR=
+               for i in `echo $INCLUDES | $SED -e's/-I//g'` $abs_srcdir ../raphf; do
+                       if test -d $i; then
+                               if test -f $i/php_raphf.h; then
+                                       HTTP_EXT_RAPHF_INCDIR=$i
+                                       break
+                               elif test -f $i/ext/raphf/php_raphf.h; then
+                                       HTTP_EXT_RAPHF_INCDIR=$i/ext/raphf
+                                       break
+                               fi
+                       fi
+               done
+               if test "x$HTTP_EXT_RAPHF_INCDIR" = "x"; then
+                       AC_MSG_FAILURE([not found])
+               else
+                       AC_MSG_RESULT([$HTTP_EXT_RAPHF_INCDIR])
+                       AC_DEFINE([PHP_HTTP_HAVE_PHP_RAPHF_H], [1], [Have ext/raphf support])
+                       PHP_ADD_INCLUDE([$HTTP_EXT_RAPHF_INCDIR])
+               fi
+       ])
+
 PHP_ARG_WITH([http-shared-deps], [whether to depend on extensions which have been built shared],
 [  --without-http-shared-deps   HTTP: do not depend on extensions like hash
                                      and iconv (when they are built shared)], $PHP_HTTP, $PHP_HTTP)
@@ -439,10 +465,8 @@ dnl ----
                php_http_object.c \
                php_http_options.c \
                php_http_params.c \
-               php_http_persistent_handle.c \
                php_http_property_proxy.c \
                php_http_querystring.c \
-               php_http_resource_factory.c \
                php_http_strlist.c \
                php_http_url.c \
                php_http_version.c \
@@ -490,10 +514,8 @@ dnl ----
                php_http_object.h \
                php_http_options.h \
                php_http_params.h \
-               php_http_persistent_handle.h \
                php_http_property_proxy.h \
                php_http_querystring.h \
-               php_http_resource_factory.h \
                php_http_strlist.h \
                php_http_url.h \
                php_http_version.h \
index 86933ea..95f8ad5 100644 (file)
@@ -44,6 +44,7 @@ PHP_RSHUTDOWN_FUNCTION(http);
 PHP_MINFO_FUNCTION(http);
 
 static zend_module_dep http_module_deps[] = {
+       ZEND_MOD_REQUIRED("raphf")
        ZEND_MOD_REQUIRED("spl")
 #ifdef PHP_HTTP_HAVE_HASH
        ZEND_MOD_REQUIRED("hash")
@@ -145,7 +146,6 @@ zend_php_http_globals *php_http_globals(void)
 
 PHP_INI_BEGIN()
        PHP_HTTP_INI_ENTRY("http.etag.mode", "crc32b", PHP_INI_ALL, OnUpdateString, env.etag_mode)
-       PHP_HTTP_INI_ENTRY("http.persistent_handle.limit", "-1", PHP_INI_SYSTEM, OnUpdateLong, persistent_handle.limit)
 PHP_INI_END()
 
 PHP_MINIT_FUNCTION(http)
@@ -159,7 +159,6 @@ PHP_MINIT_FUNCTION(http)
        if (0
        || SUCCESS != PHP_MINIT_CALL(http_object)
        || SUCCESS != PHP_MINIT_CALL(http_exception)
-       || SUCCESS != PHP_MINIT_CALL(http_persistent_handle)
        || SUCCESS != PHP_MINIT_CALL(http_cookie)
        || SUCCESS != PHP_MINIT_CALL(http_encoding)
        || SUCCESS != PHP_MINIT_CALL(http_filter)
@@ -205,7 +204,6 @@ PHP_MSHUTDOWN_FUNCTION(http)
        || SUCCESS != PHP_MSHUTDOWN_CALL(http_curl_client)
        || SUCCESS != PHP_MSHUTDOWN_CALL(http_curl)
 #endif
-       || SUCCESS != PHP_MSHUTDOWN_CALL(http_persistent_handle)
        || SUCCESS != PHP_MSHUTDOWN_CALL(http_client_factory)
        ) {
                return FAILURE;
@@ -317,50 +315,11 @@ PHP_MINFO_FUNCTION(http)
        php_http_buffer_reset(&buf);
        php_http_registered_classes(&buf, ZEND_ACC_FINAL_CLASS);
        php_info_print_table_row(2, "Final Classes", buf.data);
-       php_http_buffer_reset(&buf);
+       php_http_buffer_dtor(&buf);
 
        php_info_print_table_row(2, "Stream Filters",  "http.chunked_encode, http.chunked_decode, http.inflate, http.deflate");
        php_info_print_table_end();
 
-       php_info_print_table_start();
-       php_info_print_table_colspan_header(4, "Persistent Handles");
-       php_info_print_table_header(4, "Provider", "Ident", "Used", "Free");
-       {
-               HashTable *ht;
-               HashPosition pos1, pos2;
-               php_http_array_hashkey_t provider = php_http_array_hashkey_init(0), ident = php_http_array_hashkey_init(0);
-               zval **val, **sub, **zused, **zfree;
-               
-               if ((ht = php_http_persistent_handle_statall(NULL TSRMLS_CC)) && zend_hash_num_elements(ht)) {
-                       FOREACH_HASH_KEYVAL(pos1, ht, provider, val) {
-                               if (zend_hash_num_elements(Z_ARRVAL_PP(val))) {
-                                       FOREACH_KEYVAL(pos2, *val, ident, sub) {
-                                               if (    SUCCESS == zend_hash_find(Z_ARRVAL_PP(sub), ZEND_STRS("used"), (void *) &zused) &&
-                                                               SUCCESS == zend_hash_find(Z_ARRVAL_PP(sub), ZEND_STRS("free"), (void *) &zfree)) {
-                                                       zval *used = php_http_ztyp(IS_STRING, *zused);
-                                                       zval *free = php_http_ztyp(IS_STRING, *zfree);
-                                                       php_info_print_table_row(4, provider.str, ident.str, Z_STRVAL_P(used), Z_STRVAL_P(free));
-                                                       zval_ptr_dtor(&used);
-                                                       zval_ptr_dtor(&free);
-                                               } else {
-                                                       php_info_print_table_row(4, provider.str, ident.str, "0", "0");
-                                               }
-                                       }
-                               } else {
-                                       php_info_print_table_row(4, provider.str, "N/A", "0", "0");
-                               }
-                       }
-               } else {
-                       php_info_print_table_row(4, "N/A", "N/A", "0", "0");
-               }
-               if (ht) {
-                       zend_hash_destroy(ht);
-                       FREE_HASHTABLE(ht);
-               }
-       }
-       php_info_print_table_end();
-       
-       php_http_buffer_dtor(&buf);
 
        DISPLAY_INI_ENTRIES();
 }
index f48d464..ba01060 100644 (file)
@@ -23,6 +23,7 @@
 #include <php.h>
 #include <SAPI.h>
 
+#include <ext/raphf/php_raphf.h>
 #include <ext/standard/php_string.h>
 #include <ext/spl/spl_iterators.h>
 #include <ext/date/php_date.h>
@@ -73,7 +74,6 @@ typedef int STATUS;
 #include "php_http_buffer.h"
 #include "php_http_strlist.h"
 #include "php_http_misc.h"
-#include "php_http_resource_factory.h"
 #include "php_http_options.h"
 
 #include "php_http.h"
@@ -94,7 +94,6 @@ typedef int STATUS;
 #include "php_http_negotiate.h"
 #include "php_http_object.h"
 #include "php_http_params.h"
-#include "php_http_persistent_handle.h"
 #include "php_http_property_proxy.h"
 #include "php_http_querystring.h"
 #include "php_http_client_interface.h"
@@ -113,7 +112,6 @@ typedef int STATUS;
 
 ZEND_BEGIN_MODULE_GLOBALS(php_http)
        struct php_http_env_globals env;
-       struct php_http_persistent_handle_globals persistent_handle;
 #if PHP_HTTP_HAVE_CURL && PHP_HTTP_HAVE_EVENT
        struct php_http_curl_globals curl;
 #endif
index 29da4c9..4d109bd 100644 (file)
@@ -15,7 +15,7 @@
 #include <ext/spl/spl_observer.h>
 #include <ext/standard/php_array.h>
 
-PHP_HTTP_API php_http_client_t *php_http_client_init(php_http_client_t *h, php_http_client_ops_t *ops, php_http_resource_factory_t *rf, void *init_arg TSRMLS_DC)
+PHP_HTTP_API php_http_client_t *php_http_client_init(php_http_client_t *h, php_http_client_ops_t *ops, php_resource_factory_t *rf, void *init_arg TSRMLS_DC)
 {
        php_http_client_t *free_h = NULL;
 
@@ -28,7 +28,7 @@ PHP_HTTP_API php_http_client_t *php_http_client_init(php_http_client_t *h, php_h
        if (rf) {
                h->rf = rf;
        } else if (ops->rsrc) {
-               h->rf = php_http_resource_factory_init(NULL, h->ops->rsrc, h, NULL);
+               h->rf = php_resource_factory_init(NULL, h->ops->rsrc, h, NULL);
        }
        h->request.buffer = php_http_buffer_init(NULL);
        h->request.parser = php_http_message_parser_init(NULL TSRMLS_CC);
@@ -59,7 +59,7 @@ PHP_HTTP_API void php_http_client_dtor(php_http_client_t *h)
                h->ops->dtor(h);
        }
 
-       php_http_resource_factory_free(&h->rf);
+       php_resource_factory_free(&h->rf);
 
        php_http_message_parser_free(&h->request.parser);
        php_http_message_free(&h->request.message);
@@ -92,10 +92,10 @@ PHP_HTTP_API php_http_client_t *php_http_client_copy(php_http_client_t *from, ph
 
                to->ops = from->ops;
                if (from->rf) {
-                       php_http_resource_factory_addref(from->rf);
+                       php_resource_factory_addref(from->rf);
                        to->rf = from->rf;
                } else if (to->ops->rsrc){
-                       to->rf = php_http_resource_factory_init(NULL, to->ops->rsrc, to, NULL);
+                       to->rf = php_resource_factory_init(NULL, to->ops->rsrc, to, NULL);
                }
 
                to->request.buffer = php_http_buffer_init(NULL);
index fb4a600..3562af9 100644 (file)
@@ -107,7 +107,7 @@ typedef STATUS (*php_http_client_setopt_func_t)(struct php_http_client *h, php_h
 typedef STATUS (*php_http_client_getopt_func_t)(struct php_http_client *h, php_http_client_getopt_opt_t opt, void *arg);
 
 typedef struct php_http_client_ops {
-       php_http_resource_factory_ops_t *rsrc;
+       php_resource_factory_ops_t *rsrc;
        php_http_client_init_func_t init;
        php_http_client_copy_func_t copy;
        php_http_client_dtor_func_t dtor;
@@ -121,7 +121,7 @@ typedef struct php_http_client_ops {
 
 typedef struct php_http_client {
        void *ctx;
-       php_http_resource_factory_t *rf;
+       php_resource_factory_t *rf;
        php_http_client_ops_t *ops;
        struct {
                php_http_message_parser_t *parser;
@@ -138,7 +138,7 @@ typedef struct php_http_client {
 #endif
 } php_http_client_t;
 
-PHP_HTTP_API php_http_client_t *php_http_client_init(php_http_client_t *h, php_http_client_ops_t *ops, php_http_resource_factory_t *rf, void *init_arg TSRMLS_DC);
+PHP_HTTP_API php_http_client_t *php_http_client_init(php_http_client_t *h, php_http_client_ops_t *ops, php_resource_factory_t *rf, void *init_arg TSRMLS_DC);
 PHP_HTTP_API php_http_client_t *php_http_client_copy(php_http_client_t *from, php_http_client_t *to);
 PHP_HTTP_API STATUS php_http_client_exec(php_http_client_t *h, php_http_message_t *msg);
 PHP_HTTP_API STATUS php_http_client_reset(php_http_client_t *h);
index 4b92939..69661c7 100644 (file)
@@ -15,7 +15,7 @@
 
 static int php_http_client_datashare_compare_handles(void *h1, void *h2);
 
-PHP_HTTP_API php_http_client_datashare_t *php_http_client_datashare_init(php_http_client_datashare_t *h, php_http_client_datashare_ops_t *ops, php_http_resource_factory_t *rf, void *init_arg TSRMLS_DC)
+PHP_HTTP_API php_http_client_datashare_t *php_http_client_datashare_init(php_http_client_datashare_t *h, php_http_client_datashare_ops_t *ops, php_resource_factory_t *rf, void *init_arg TSRMLS_DC)
 {
        php_http_client_datashare_t *free_h = NULL;
 
@@ -29,7 +29,7 @@ PHP_HTTP_API php_http_client_datashare_t *php_http_client_datashare_init(php_htt
        if (rf) {
                h->rf = rf;
        } else if (ops->rsrc) {
-               h->rf = php_http_resource_factory_init(NULL, h->ops->rsrc, h, NULL);
+               h->rf = php_resource_factory_init(NULL, h->ops->rsrc, h, NULL);
        }
        TSRMLS_SET_CTX(h->ts);
 
@@ -59,7 +59,7 @@ PHP_HTTP_API void php_http_client_datashare_dtor(php_http_client_datashare_t *h)
                h->ops->dtor(h);
        }
        zend_llist_destroy(&h->clients);
-       php_http_resource_factory_free(&h->rf);
+       php_resource_factory_free(&h->rf);
 }
 
 PHP_HTTP_API void php_http_client_datashare_free(php_http_client_datashare_t **h)
index c60ff39..8e66b68 100644 (file)
@@ -28,7 +28,7 @@ typedef STATUS (*php_http_client_datashare_detach_func_t)(struct php_http_client
 typedef STATUS (*php_http_client_datashare_setopt_func_t)(struct php_http_client_datashare *h, php_http_client_datashare_setopt_opt_t opt, void *arg);
 
 typedef struct php_http_client_datashare_ops {
-       php_http_resource_factory_ops_t *rsrc;
+       php_resource_factory_ops_t *rsrc;
        php_http_client_datashare_init_func_t init;
        php_http_client_datashare_copy_func_t copy;
        php_http_client_datashare_dtor_func_t dtor;
@@ -42,7 +42,7 @@ typedef struct php_http_client_datashare_ops {
 
 typedef struct php_http_client_datashare {
        void *ctx;
-       php_http_resource_factory_t *rf;
+       php_resource_factory_t *rf;
        php_http_client_datashare_ops_t *ops;
        zend_llist clients;
 #ifdef ZTS
@@ -52,7 +52,7 @@ typedef struct php_http_client_datashare {
 
 PHP_MINIT_FUNCTION(http_client_datashare);
 
-PHP_HTTP_API php_http_client_datashare_t *php_http_client_datashare_init(php_http_client_datashare_t *h, php_http_client_datashare_ops_t *ops, php_http_resource_factory_t *rf, void *init_arg TSRMLS_DC);
+PHP_HTTP_API php_http_client_datashare_t *php_http_client_datashare_init(php_http_client_datashare_t *h, php_http_client_datashare_ops_t *ops, php_resource_factory_t *rf, void *init_arg TSRMLS_DC);
 PHP_HTTP_API php_http_client_datashare_t *php_http_client_datashare_copy(php_http_client_datashare_t *from, php_http_client_datashare_t *to);
 PHP_HTTP_API void php_http_client_datashare_dtor(php_http_client_datashare_t *h);
 PHP_HTTP_API void php_http_client_datashare_free(php_http_client_datashare_t **h);
index d97f686..ef77424 100644 (file)
@@ -130,17 +130,17 @@ PHP_METHOD(HttpClientFactory, createClient)
 
                                if ((IS_STRING == Z_TYPE_P(zdriver)) && (SUCCESS == php_http_client_factory_get_driver(Z_STRVAL_P(zdriver), Z_STRLEN_P(zdriver), &driver)) && driver.client_ops) {
                                        zval *phi = php_http_zsep(1, IS_STRING, zend_read_property(php_http_client_factory_class_entry, getThis(), ZEND_STRL("persistentHandleId"), 0 TSRMLS_CC));
-                                       php_http_resource_factory_t *rf = NULL;
+                                       php_resource_factory_t *rf = NULL;
 
                                        if (Z_STRLEN_P(phi)) {
                                                char *name_str;
                                                size_t name_len;
-                                               php_http_persistent_handle_factory_t *pf;
+                                               php_persistent_handle_factory_t *pf;
 
                                                name_len = spprintf(&name_str, 0, "http_client.%s", Z_STRVAL_P(zdriver));
 
-                                               if ((pf = php_http_persistent_handle_concede(NULL , name_str, name_len, Z_STRVAL_P(phi), Z_STRLEN_P(phi) TSRMLS_CC))) {
-                                                       rf = php_http_resource_factory_init(NULL, php_http_persistent_handle_resource_factory_ops(), pf, (void (*)(void *)) php_http_persistent_handle_abandon);
+                                               if ((pf = php_persistent_handle_concede(NULL , name_str, name_len, Z_STRVAL_P(phi), Z_STRLEN_P(phi) TSRMLS_CC))) {
+                                                       rf = php_resource_factory_init(NULL, php_persistent_handle_get_resource_factory_ops(), pf, (void (*)(void *)) php_persistent_handle_abandon);
                                                }
 
                                                efree(name_str);
@@ -187,17 +187,17 @@ PHP_METHOD(HttpClientFactory, createPool)
                                zdriver = zend_read_property(php_http_client_factory_class_entry, getThis(), ZEND_STRL("driver"), 0 TSRMLS_CC);
                                if ((IS_STRING == Z_TYPE_P(zdriver)) && (SUCCESS == php_http_client_factory_get_driver(Z_STRVAL_P(zdriver), Z_STRLEN_P(zdriver), &driver)) && driver.client_pool_ops) {
                                        zval *phi = php_http_zsep(1, IS_STRING, zend_read_property(php_http_client_factory_class_entry, getThis(), ZEND_STRL("persistentHandleId"), 0 TSRMLS_CC));
-                                       php_http_resource_factory_t *rf = NULL;
+                                       php_resource_factory_t *rf = NULL;
 
                                        if (Z_STRLEN_P(phi)) {
                                                char *name_str;
                                                size_t name_len;
-                                               php_http_persistent_handle_factory_t *pf;
+                                               php_persistent_handle_factory_t *pf;
 
                                                name_len = spprintf(&name_str, 0, "http_client_pool.%s", Z_STRVAL_P(zdriver));
 
-                                               if ((pf = php_http_persistent_handle_concede(NULL , name_str, name_len, Z_STRVAL_P(phi), Z_STRLEN_P(phi) TSRMLS_CC))) {
-                                                       rf = php_http_resource_factory_init(NULL, php_http_persistent_handle_resource_factory_ops(), pf, (void (*)(void *)) php_http_persistent_handle_abandon);
+                                               if ((pf = php_persistent_handle_concede(NULL , name_str, name_len, Z_STRVAL_P(phi), Z_STRLEN_P(phi) TSRMLS_CC))) {
+                                                       rf = php_resource_factory_init(NULL, php_persistent_handle_get_resource_factory_ops(), pf, (void (*)(void *)) php_persistent_handle_abandon);
                                                }
 
                                                efree(name_str);
@@ -252,17 +252,17 @@ PHP_METHOD(HttpClientFactory, createDataShare)
                                zdriver = zend_read_property(php_http_client_factory_class_entry, getThis(), ZEND_STRL("driver"), 0 TSRMLS_CC);
                                if ((IS_STRING == Z_TYPE_P(zdriver)) && (SUCCESS == php_http_client_factory_get_driver(Z_STRVAL_P(zdriver), Z_STRLEN_P(zdriver), &driver)) && driver.client_datashare_ops) {
                                        zval *phi = php_http_zsep(1, IS_STRING, zend_read_property(php_http_client_factory_class_entry, getThis(), ZEND_STRL("persistentHandleId"), 0 TSRMLS_CC));
-                                       php_http_resource_factory_t *rf = NULL;
+                                       php_resource_factory_t *rf = NULL;
 
                                        if (Z_STRLEN_P(phi)) {
                                                char *name_str;
                                                size_t name_len;
-                                               php_http_persistent_handle_factory_t *pf;
+                                               php_persistent_handle_factory_t *pf;
 
                                                name_len = spprintf(&name_str, 0, "http_client_datashare.%s", Z_STRVAL_P(zdriver));
 
-                                               if ((pf = php_http_persistent_handle_concede(NULL , name_str, name_len, Z_STRVAL_P(phi), Z_STRLEN_P(phi) TSRMLS_CC))) {
-                                                       rf = php_http_resource_factory_init(NULL, php_http_persistent_handle_resource_factory_ops(), pf, (void (*)(void *)) php_http_persistent_handle_abandon);
+                                               if ((pf = php_persistent_handle_concede(NULL , name_str, name_len, Z_STRVAL_P(phi), Z_STRLEN_P(phi) TSRMLS_CC))) {
+                                                       rf = php_resource_factory_init(NULL, php_persistent_handle_get_resource_factory_ops(), pf, (void (*)(void *)) php_persistent_handle_abandon);
                                                }
 
                                                efree(name_str);
index 04a7306..3e6b6f9 100644 (file)
@@ -12,7 +12,7 @@
 
 #include "php_http_api.h"
 
-PHP_HTTP_API php_http_client_pool_t *php_http_client_pool_init(php_http_client_pool_t *h, php_http_client_pool_ops_t *ops, php_http_resource_factory_t *rf, void *init_arg TSRMLS_DC)
+PHP_HTTP_API php_http_client_pool_t *php_http_client_pool_init(php_http_client_pool_t *h, php_http_client_pool_ops_t *ops, php_resource_factory_t *rf, void *init_arg TSRMLS_DC)
 {
        php_http_client_pool_t *free_h = NULL;
 
@@ -25,7 +25,7 @@ PHP_HTTP_API php_http_client_pool_t *php_http_client_pool_init(php_http_client_p
        if (rf) {
                h->rf = rf;
        } else if (ops->rsrc) {
-               h->rf = php_http_resource_factory_init(NULL, h->ops->rsrc, h, NULL);
+               h->rf = php_resource_factory_init(NULL, h->ops->rsrc, h, NULL);
        }
        zend_llist_init(&h->clients.attached, sizeof(zval *), (llist_dtor_func_t) ZVAL_PTR_DTOR, 0);
        zend_llist_init(&h->clients.finished, sizeof(zval *), (llist_dtor_func_t) ZVAL_PTR_DTOR, 0);
@@ -61,7 +61,7 @@ PHP_HTTP_API void php_http_client_pool_dtor(php_http_client_pool_t *h)
        zend_llist_clean(&h->clients.finished);
        zend_llist_clean(&h->clients.attached);
 
-       php_http_resource_factory_free(&h->rf);
+       php_resource_factory_free(&h->rf);
 }
 
 PHP_HTTP_API void php_http_client_pool_free(php_http_client_pool_t **h) {
index 071042d..17bfe13 100644 (file)
@@ -30,7 +30,7 @@ typedef STATUS (*php_http_client_pool_detach_func_t)(struct php_http_client_pool
 typedef STATUS (*php_http_client_pool_setopt_func_t)(struct php_http_client_pool *p, php_http_client_pool_setopt_opt_t opt, void *arg);
 
 typedef struct php_http_client_pool_ops {
-       php_http_resource_factory_ops_t *rsrc;
+       php_resource_factory_ops_t *rsrc;
        php_http_client_pool_init_func_t init;
        php_http_client_pool_copy_func_t copy;
        php_http_client_pool_dtor_func_t dtor;
@@ -47,7 +47,7 @@ typedef struct php_http_client_pool_ops {
 
 typedef struct php_http_client_pool {
        void *ctx;
-       php_http_resource_factory_t *rf;
+       php_resource_factory_t *rf;
        php_http_client_pool_ops_t *ops;
 
        struct {
@@ -61,7 +61,7 @@ typedef struct php_http_client_pool {
 #endif
 } php_http_client_pool_t;
 
-PHP_HTTP_API php_http_client_pool_t *php_http_client_pool_init(php_http_client_pool_t *pool, php_http_client_pool_ops_t *ops, php_http_resource_factory_t *rf, void *init_arg TSRMLS_DC);
+PHP_HTTP_API php_http_client_pool_t *php_http_client_pool_init(php_http_client_pool_t *pool, php_http_client_pool_ops_t *ops, php_resource_factory_t *rf, void *init_arg TSRMLS_DC);
 PHP_HTTP_API php_http_client_pool_t *php_http_client_pool_copy(php_http_client_pool_t *from, php_http_client_pool_t *to);
 PHP_HTTP_API void php_http_client_pool_dtor(php_http_client_pool_t *pool);
 PHP_HTTP_API void php_http_client_pool_free(php_http_client_pool_t **pool);
index c0930db..23b8855 100644 (file)
@@ -14,7 +14,7 @@
 
 /* resource_factory ops */
 
-static void *php_http_curl_ctor(void *opaque TSRMLS_DC)
+static void *php_http_curl_ctor(void *opaque, void *init_arg TSRMLS_DC)
 {
        void *ch;
 
@@ -1011,7 +1011,7 @@ static php_http_client_t *php_http_curl_client_init(php_http_client_t *h, void *
        php_http_curl_client_t *ctx;
        TSRMLS_FETCH_FROM_CTX(h->ts);
 
-       if (!handle && !(handle = php_http_resource_factory_handle_ctor(h->rf TSRMLS_CC))) {
+       if (!handle && !(handle = php_resource_factory_handle_ctor(h->rf, NULL TSRMLS_CC))) {
                php_http_error(HE_WARNING, PHP_HTTP_E_CLIENT, "could not initialize curl handle");
                return NULL;
        }
@@ -1051,7 +1051,7 @@ static php_http_client_t *php_http_curl_client_copy(php_http_client_t *from, php
        void *copy;
        TSRMLS_FETCH_FROM_CTX(from->ts);
 
-       if (!(copy = php_http_resource_factory_handle_copy(from->rf, ctx->handle TSRMLS_CC))) {
+       if (!(copy = php_resource_factory_handle_copy(from->rf, ctx->handle TSRMLS_CC))) {
                return NULL;
        }
 
@@ -1072,7 +1072,7 @@ static void php_http_curl_client_dtor(php_http_client_t *h)
        curl_easy_setopt(ctx->handle, CURLOPT_VERBOSE, 0L);
        curl_easy_setopt(ctx->handle, CURLOPT_DEBUGFUNCTION, NULL);
 
-       php_http_resource_factory_handle_dtor(h->rf, ctx->handle TSRMLS_CC);
+       php_resource_factory_handle_dtor(h->rf, ctx->handle TSRMLS_CC);
 
        php_http_buffer_dtor(&ctx->options.ranges);
        php_http_buffer_dtor(&ctx->options.cookies);
@@ -1353,7 +1353,7 @@ static STATUS php_http_curl_client_getopt(php_http_client_t *h, php_http_client_
        return SUCCESS;
 }
 
-static php_http_resource_factory_ops_t php_http_curl_client_resource_factory_ops = {
+static php_resource_factory_ops_t php_http_curl_client_resource_factory_ops = {
        php_http_curl_ctor,
        php_http_curl_copy,
        php_http_curl_dtor
@@ -1432,7 +1432,7 @@ PHP_MINIT_FUNCTION(http_curl_client)
 {
        php_http_options_t *options;
 
-       if (SUCCESS != php_http_persistent_handle_provide(ZEND_STRL("http_client.curl"), &php_http_curl_client_resource_factory_ops, NULL, NULL)) {
+       if (SUCCESS != php_persistent_handle_provide(ZEND_STRL("http_client.curl"), &php_http_curl_client_resource_factory_ops, NULL, NULL)) {
                return FAILURE;
        }
 
index 3668512..1957c2b 100644 (file)
@@ -19,7 +19,7 @@ typedef struct php_http_curl_client_datashare {
 } php_http_curl_client_datashare_t;
 
 
-static void *php_http_curlsh_ctor(void *opaque TSRMLS_DC)
+static void *php_http_curlsh_ctor(void *opaque, void *init_arg TSRMLS_DC)
 {
        return curl_share_init();
 }
@@ -37,7 +37,7 @@ static php_http_client_datashare_t *php_http_curl_client_datashare_init(php_http
        php_http_curl_client_datashare_t *curl;
        TSRMLS_FETCH_FROM_CTX(h->ts);
 
-       if (!handle && !(handle = php_http_resource_factory_handle_ctor(h->rf TSRMLS_CC))) {
+       if (!handle && !(handle = php_resource_factory_handle_ctor(h->rf, NULL TSRMLS_CC))) {
                php_http_error(HE_WARNING, PHP_HTTP_E_CLIENT_DATASHARE, "could not initialize curl share handle");
                return NULL;
        }
@@ -54,7 +54,7 @@ static void php_http_curl_client_datashare_dtor(php_http_client_datashare_t *h)
        php_http_curl_client_datashare_t *curl = h->ctx;
        TSRMLS_FETCH_FROM_CTX(h->ts);
 
-       php_http_resource_factory_handle_dtor(h->rf, curl->handle TSRMLS_CC);
+       php_resource_factory_handle_dtor(h->rf, curl->handle TSRMLS_CC);
 
        efree(curl);
        h->ctx = NULL;
@@ -140,7 +140,7 @@ static STATUS php_http_curl_client_datashare_setopt(php_http_client_datashare_t
        return SUCCESS;
 }
 
-static php_http_resource_factory_ops_t php_http_curlsh_resource_factory_ops = {
+static php_resource_factory_ops_t php_http_curlsh_resource_factory_ops = {
        php_http_curlsh_ctor,
        NULL,
        php_http_curlsh_dtor
@@ -212,7 +212,7 @@ zend_object_value php_http_curl_client_datashare_object_new_ex(zend_class_entry
 
 PHP_MINIT_FUNCTION(http_curl_client_datashare)
 {
-       if (SUCCESS != php_http_persistent_handle_provide(ZEND_STRL("http_client_datashare.curl"), &php_http_curlsh_resource_factory_ops, NULL, NULL)) {
+       if (SUCCESS != php_persistent_handle_provide(ZEND_STRL("http_client_datashare.curl"), &php_http_curlsh_resource_factory_ops, NULL, NULL)) {
                return FAILURE;
        }
 
index 4edff74..6d04b53 100644 (file)
@@ -37,7 +37,7 @@ typedef struct php_http_curl_client_pool {
 #endif
 } php_http_curl_client_pool_t;
 
-static void *php_http_curlm_ctor(void *opaque TSRMLS_DC)
+static void *php_http_curlm_ctor(void *opaque, void *init_arg TSRMLS_DC)
 {
        return curl_multi_init();
 }
@@ -246,7 +246,7 @@ static php_http_client_pool_t *php_http_curl_client_pool_init(php_http_client_po
        php_http_curl_client_pool_t *curl;
        TSRMLS_FETCH_FROM_CTX(h->ts);
 
-       if (!handle && !(handle = php_http_resource_factory_handle_ctor(h->rf TSRMLS_CC))) {
+       if (!handle && !(handle = php_resource_factory_handle_ctor(h->rf, NULL TSRMLS_CC))) {
                php_http_error(HE_WARNING, PHP_HTTP_E_CLIENT_POOL, "could not initialize curl pool handle");
                return NULL;
        }
@@ -273,7 +273,7 @@ static void php_http_curl_client_pool_dtor(php_http_client_pool_t *h)
        curl->unfinished = 0;
        php_http_client_pool_reset(h);
 
-       php_http_resource_factory_handle_dtor(h->rf, curl->handle TSRMLS_CC);
+       php_resource_factory_handle_dtor(h->rf, curl->handle TSRMLS_CC);
 
        efree(curl);
        h->ctx = NULL;
@@ -471,7 +471,7 @@ static STATUS php_http_curl_client_pool_setopt(php_http_client_pool_t *h, php_ht
        return SUCCESS;
 }
 
-static php_http_resource_factory_ops_t php_http_curlm_resource_factory_ops = {
+static php_resource_factory_ops_t php_http_curlm_resource_factory_ops = {
        php_http_curlm_ctor,
        NULL,
        php_http_curlm_dtor
@@ -546,7 +546,7 @@ zend_object_value php_http_curl_client_pool_object_new_ex(zend_class_entry *ce,
 
 PHP_MINIT_FUNCTION(http_curl_client_pool)
 {
-       if (SUCCESS != php_http_persistent_handle_provide(ZEND_STRL("http_client_pool.curl"), &php_http_curlm_resource_factory_ops, NULL, NULL)) {
+       if (SUCCESS != php_persistent_handle_provide(ZEND_STRL("http_client_pool.curl"), &php_http_curlm_resource_factory_ops, NULL, NULL)) {
                return FAILURE;
        }
 
index c8c3d2c..ee7d27f 100644 (file)
@@ -741,13 +741,6 @@ PHP_HTTP_BEGIN_ARGS(negotiate, 2)
        PHP_HTTP_ARG_VAL(result_array, 1)
 PHP_HTTP_END_ARGS;
 
-PHP_HTTP_EMPTY_ARGS(statPersistentHandles);
-
-PHP_HTTP_BEGIN_ARGS(cleanPersistentHandles, 0)
-       PHP_HTTP_ARG_VAL(name, 0)
-       PHP_HTTP_ARG_VAL(ident, 0)
-PHP_HTTP_END_ARGS;
-
 static zend_class_entry *php_http_env_class_entry;
 
 zend_class_entry *php_http_env_get_class_entry(void)
@@ -773,9 +766,6 @@ static zend_function_entry php_http_env_method_entry[] = {
        PHP_HTTP_ENV_ME(negotiateCharset)
        PHP_HTTP_ENV_ME(negotiate)
 
-       PHP_HTTP_ENV_ME(statPersistentHandles)
-       PHP_HTTP_ENV_ME(cleanPersistentHandles)
-
        EMPTY_FUNCTION_ENTRY
 };
 
@@ -991,28 +981,6 @@ PHP_METHOD(HttpEnv, negotiate)
        }
 }
 
-PHP_METHOD(HttpEnv, statPersistentHandles)
-{
-       if (SUCCESS == zend_parse_parameters_none()) {
-               object_init(return_value);
-               if (php_http_persistent_handle_statall(HASH_OF(return_value) TSRMLS_CC)) {
-                       return;
-               }
-               zval_dtor(return_value);
-       }
-       RETURN_FALSE;
-}
-
-PHP_METHOD(HttpEnv, cleanPersistentHandles)
-{
-       char *name_str = NULL, *ident_str = NULL;
-       int name_len = 0, ident_len = 0;
-
-       if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!s!", &name_str, &name_len, &ident_str, &ident_len)) {
-               php_http_persistent_handle_cleanup(name_str, name_len, ident_str, ident_len TSRMLS_CC);
-       }
-}
-
 #ifdef PHP_HTTP_HAVE_JSON
 #include "ext/json/php_json.h"
 
index b9b4fd5..c78ced6 100644 (file)
@@ -87,8 +87,6 @@ PHP_METHOD(HttpEnv, negotiateCharset);
 PHP_METHOD(HttpEnv, negotiateEncoding);
 PHP_METHOD(HttpEnv, negotiateContentType);
 PHP_METHOD(HttpEnv, negotiate);
-PHP_METHOD(HttpEnv, statPersistentHandles);
-PHP_METHOD(HttpEnv, cleanPersistentHandles);
 
 PHP_MINIT_FUNCTION(http_env);
 PHP_RINIT_FUNCTION(http_env);
diff --git a/php_http_persistent_handle.c b/php_http_persistent_handle.c
deleted file mode 100644 (file)
index d27663c..0000000
+++ /dev/null
@@ -1,427 +0,0 @@
-/*
-    +--------------------------------------------------------------------+
-    | PECL :: http                                                       |
-    +--------------------------------------------------------------------+
-    | Redistribution and use in source and binary forms, with or without |
-    | modification, are permitted provided that the conditions mentioned |
-    | in the accompanying LICENSE file are met.                          |
-    +--------------------------------------------------------------------+
-    | Copyright (c) 2004-2011, Michael Wallner <mike@php.net>            |
-    +--------------------------------------------------------------------+
-*/
-
-#include "php_http_api.h"
-
-#ifndef PHP_HTTP_DEBUG_PHANDLES
-#      define PHP_HTTP_DEBUG_PHANDLES 0
-#endif
-#if PHP_HTTP_DEBUG_PHANDLES
-#      undef inline
-#      define inline
-#endif
-
-static HashTable php_http_persistent_handles_hash;
-#ifdef ZTS
-#      define LOCK() tsrm_mutex_lock(php_http_persistent_handles_lock)
-#      define UNLOCK() tsrm_mutex_unlock(php_http_persistent_handles_lock)
-static MUTEX_T php_http_persistent_handles_lock;
-#else
-#      define LOCK()
-#      define UNLOCK()
-#endif
-
-typedef struct php_http_persistent_handle_list {
-       HashTable free;
-       ulong used;
-} php_http_persistent_handle_list_t;
-
-typedef struct php_http_persistent_handle_provider {
-       php_http_persistent_handle_list_t list; /* "ident" => array(handles) entries */
-       php_http_resource_factory_t rf;
-} php_http_persistent_handle_provider_t;
-
-static inline php_http_persistent_handle_list_t *php_http_persistent_handle_list_init(php_http_persistent_handle_list_t *list)
-{
-       int free_list;
-       
-       if ((free_list = !list)) {
-               list = pemalloc(sizeof(php_http_persistent_handle_list_t), 1);
-       }
-       
-       list->used = 0;
-       
-       if (SUCCESS != zend_hash_init(&list->free, 0, NULL, NULL, 1)) {
-               if (free_list) {
-                       pefree(list, 1);
-               }
-               list = NULL;
-       }
-       
-       return list;
-}
-
-static int php_http_persistent_handle_apply_cleanup_ex(void *pp, void *arg TSRMLS_DC)
-{
-       php_http_resource_factory_t *rf = arg;
-       void **handle = pp;
-
-#if PHP_HTTP_DEBUG_PHANDLES
-       fprintf(stderr, "DESTROY: %p\n", *handle);
-#endif
-       php_http_resource_factory_handle_dtor(rf, *handle TSRMLS_CC);
-       return ZEND_HASH_APPLY_REMOVE;
-}
-
-static int php_http_persistent_handle_apply_cleanup(void *pp, void *arg TSRMLS_DC)
-{
-       php_http_resource_factory_t *rf = arg;
-       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);
-       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)
-{
-#if PHP_HTTP_DEBUG_PHANDLES
-       fprintf(stderr, "LSTDTOR: %p\n", list);
-#endif
-       zend_hash_apply_with_argument(&list->free, php_http_persistent_handle_apply_cleanup_ex, &provider->rf TSRMLS_CC);
-       zend_hash_destroy(&list->free);
-}
-
-static inline void php_http_persistent_handle_list_free(php_http_persistent_handle_list_t **list, php_http_persistent_handle_provider_t *provider TSRMLS_DC)
-{
-       php_http_persistent_handle_list_dtor(*list, provider TSRMLS_CC);
-#if PHP_HTTP_DEBUG_PHANDLES
-       fprintf(stderr, "LSTFREE: %p\n", *list);
-#endif
-       pefree(*list, 1);
-       *list = NULL;
-}
-
-static int php_http_persistent_handle_list_apply_dtor(void *listp, void *provider TSRMLS_DC)
-{
-       php_http_persistent_handle_list_free(listp, provider TSRMLS_CC);
-       return ZEND_HASH_APPLY_REMOVE;
-}
-
-static inline php_http_persistent_handle_list_t *php_http_persistent_handle_list_find(php_http_persistent_handle_provider_t *provider, const char *ident_str, size_t ident_len TSRMLS_DC)
-{
-       php_http_persistent_handle_list_t **list, *new_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
-               return *list;
-       }
-       
-       if ((new_list = php_http_persistent_handle_list_init(NULL))) {
-               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
-                       return *list;
-               }
-               php_http_persistent_handle_list_free(&new_list, provider TSRMLS_CC);
-       }
-       
-       return NULL;
-}
-
-static inline STATUS php_http_persistent_handle_do_acquire(php_http_persistent_handle_provider_t *provider, const char *ident_str, size_t ident_len, void **handle TSRMLS_DC)
-{
-       ulong index;
-       void **handle_ptr;
-       php_http_persistent_handle_list_t *list;
-       
-       if ((list = php_http_persistent_handle_list_find(provider, ident_str, ident_len TSRMLS_CC))) {
-               zend_hash_internal_pointer_end(&list->free);
-               if (HASH_KEY_NON_EXISTANT != zend_hash_get_current_key(&list->free, NULL, &index, 0) && SUCCESS == zend_hash_get_current_data(&list->free, (void *) &handle_ptr)) {
-                       *handle = *handle_ptr;
-                       zend_hash_index_del(&list->free, index);
-               } 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;
-                       return SUCCESS;
-               }
-       } else {
-               *handle = NULL;
-       }
-       
-       return FAILURE;
-}
-
-static inline STATUS php_http_persistent_handle_do_release(php_http_persistent_handle_provider_t *provider, const char *ident_str, size_t ident_len, void **handle TSRMLS_DC)
-{
-       php_http_persistent_handle_list_t *list;
-       
-       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)) {
-                               return FAILURE;
-                       }
-               }
-               
-               *handle = NULL;
-               --provider->list.used;
-               --list->used;
-               return SUCCESS;
-       }
-       
-       return FAILURE;
-}
-
-static inline STATUS php_http_persistent_handle_do_accrete(php_http_persistent_handle_provider_t *provider, const char *ident_str, size_t ident_len, void *old_handle, void **new_handle TSRMLS_DC)
-{
-       php_http_persistent_handle_list_t *list;
-       
-       if ((*new_handle = php_http_resource_factory_handle_copy(&provider->rf, old_handle TSRMLS_CC))) {
-               if ((list = php_http_persistent_handle_list_find(provider, ident_str, ident_len TSRMLS_CC))) {
-                       ++list->used;
-               }
-               ++provider->list.used;
-               return SUCCESS;
-       }
-       return FAILURE;
-}
-
-static void php_http_persistent_handles_hash_dtor(void *p)
-{
-       php_http_persistent_handle_provider_t *provider = (php_http_persistent_handle_provider_t *) p;
-       TSRMLS_FETCH();
-       
-       zend_hash_apply_with_argument(&provider->list.free, php_http_persistent_handle_list_apply_dtor, provider TSRMLS_CC);
-       zend_hash_destroy(&provider->list.free);
-       php_http_resource_factory_dtor(&provider->rf);
-}
-
-PHP_MINIT_FUNCTION(http_persistent_handle)
-{
-       zend_hash_init(&php_http_persistent_handles_hash, 0, NULL, php_http_persistent_handles_hash_dtor, 1);
-#ifdef ZTS
-       php_http_persistent_handles_lock = tsrm_mutex_alloc();
-#endif
-       return SUCCESS;
-}
-
-PHP_MSHUTDOWN_FUNCTION(http_persistent_handle)
-{
-       zend_hash_destroy(&php_http_persistent_handles_hash);
-#ifdef ZTS
-       tsrm_mutex_free(php_http_persistent_handles_lock);
-#endif
-       return SUCCESS;
-}
-
-PHP_HTTP_API STATUS php_http_persistent_handle_provide(const char *name_str, size_t name_len, php_http_resource_factory_ops_t *fops, void *data, void (*dtor)(void *))
-{
-       STATUS status = FAILURE;
-       php_http_persistent_handle_provider_t provider;
-       
-       LOCK();
-       if (php_http_persistent_handle_list_init(&provider.list)) {
-               if (php_http_resource_factory_init(&provider.rf, fops, data, dtor)) {
-#if PHP_HTTP_DEBUG_PHANDLES
-                       fprintf(stderr, "PROVIDE: %s\n", name_str);
-#endif
-               
-                       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);
-                       }
-               }
-       }
-       UNLOCK();
-       
-       return status;
-}
-
-PHP_HTTP_API php_http_persistent_handle_factory_t *php_http_persistent_handle_concede(php_http_persistent_handle_factory_t *a, const char *name_str, size_t name_len, const char *ident_str, size_t ident_len TSRMLS_DC)
-{
-       STATUS status = FAILURE;
-       php_http_persistent_handle_factory_t *free_a = NULL;
-
-       if (!a) {
-               free_a = a = emalloc(sizeof(*a));
-       }
-       memset(a, 0, sizeof(*a));
-
-       LOCK();
-       status = zend_symtable_find(&php_http_persistent_handles_hash, name_str, name_len+1, (void *) &a->provider);
-       UNLOCK();
-
-       if (SUCCESS == status) {
-               a->ident.str = estrndup(ident_str, a->ident.len = ident_len);
-               if (free_a) {
-                       a->free_on_abandon = 1;
-               }
-       } else {
-               if (free_a) {
-                       efree(free_a);
-               }
-               a = NULL;
-       }
-
-#if PHP_HTTP_DEBUG_PHANDLES
-       fprintf(stderr, "CONCEDE: %p (%s) (%s)\n", a ? a->provider : NULL, name_str, ident_str);
-#endif
-
-       return a;
-}
-
-PHP_HTTP_API void php_http_persistent_handle_abandon(php_http_persistent_handle_factory_t *a)
-{
-       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) {
-               efree(a);
-       }
-}
-
-PHP_HTTP_API void *php_http_persistent_handle_acquire(php_http_persistent_handle_factory_t *a TSRMLS_DC)
-{
-       void *handle = NULL;
-
-       LOCK();
-       php_http_persistent_handle_do_acquire(a->provider, a->ident.str, a->ident.len, &handle TSRMLS_CC);
-       UNLOCK();
-
-       return handle;
-}
-
-PHP_HTTP_API void *php_http_persistent_handle_accrete(php_http_persistent_handle_factory_t *a, void *handle TSRMLS_DC)
-{
-       void *new_handle = NULL;
-
-       LOCK();
-       php_http_persistent_handle_do_accrete(a->provider, a->ident.str, a->ident.len, handle, &new_handle TSRMLS_CC);
-       UNLOCK();
-
-       return new_handle;
-}
-
-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 TSRMLS_CC);
-       UNLOCK();
-}
-
-PHP_HTTP_API void php_http_persistent_handle_cleanup(const char *name_str, size_t name_len, const char *ident_str, size_t ident_len TSRMLS_DC)
-{
-       php_http_persistent_handle_provider_t *provider;
-       php_http_persistent_handle_list_t *list;
-       
-       LOCK();
-       if (name_str && name_len) {
-               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))) {
-                                       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->rf TSRMLS_CC);
-                       }
-               }
-       } else {
-               HashPosition pos;
-
-               FOREACH_HASH_VAL(pos, &php_http_persistent_handles_hash, provider) {
-                       if (ident_str && ident_len) {
-                               if ((list = php_http_persistent_handle_list_find(provider, ident_str, ident_len TSRMLS_CC))) {
-                                       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->rf TSRMLS_CC);
-                       }
-               }
-       }
-       UNLOCK();
-}
-
-PHP_HTTP_API HashTable *php_http_persistent_handle_statall(HashTable *ht TSRMLS_DC)
-{
-       zval *zentry[2];
-       HashPosition pos1, pos2;
-       php_http_array_hashkey_t key1 = php_http_array_hashkey_init(0), key2 = php_http_array_hashkey_init(0);
-       php_http_persistent_handle_provider_t *provider;
-       php_http_persistent_handle_list_t **list;
-       
-       LOCK();
-       if (zend_hash_num_elements(&php_http_persistent_handles_hash)) {
-               if (!ht) {
-                       ALLOC_HASHTABLE(ht);
-                       zend_hash_init(ht, 0, NULL, ZVAL_PTR_DTOR, 0);
-               }
-               
-               FOREACH_HASH_KEYVAL(pos1, &php_http_persistent_handles_hash, key1, provider) {
-                       MAKE_STD_ZVAL(zentry[0]);
-                       array_init(zentry[0]);
-                       
-                       FOREACH_HASH_KEYVAL(pos2, &provider->list.free, key2, list) {
-                               MAKE_STD_ZVAL(zentry[1]);
-                               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));
-                               add_assoc_zval_ex(zentry[0], key2.str, key2.len, zentry[1]);
-                       }
-                       
-                       zend_symtable_update(ht, key1.str, key1.len, &zentry[0], sizeof(zval *), NULL);
-               }
-       } else if (ht) {
-               ht = NULL;
-       }
-       UNLOCK();
-       
-       return ht;
-}
-
-static php_http_resource_factory_ops_t php_http_persistent_handle_rf_ops = {
-       (php_http_resource_factory_handle_ctor_t) php_http_persistent_handle_acquire,
-       (php_http_resource_factory_handle_copy_t) php_http_persistent_handle_accrete,
-       (php_http_resource_factory_handle_dtor_t) php_http_persistent_handle_release
-};
-
-PHP_HTTP_API php_http_resource_factory_ops_t *php_http_persistent_handle_resource_factory_ops(void)
-{
-       return &php_http_persistent_handle_rf_ops;
-}
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
-
diff --git a/php_http_persistent_handle.h b/php_http_persistent_handle.h
deleted file mode 100644 (file)
index b94cafe..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
-    +--------------------------------------------------------------------+
-    | PECL :: http                                                       |
-    +--------------------------------------------------------------------+
-    | Redistribution and use in source and binary forms, with or without |
-    | modification, are permitted provided that the conditions mentioned |
-    | in the accompanying LICENSE file are met.                          |
-    +--------------------------------------------------------------------+
-    | Copyright (c) 2004-2011, Michael Wallner <mike@php.net>            |
-    +--------------------------------------------------------------------+
-*/
-
-#ifndef PHP_HTTP_PERSISTENT_HANDLE_H
-#define PHP_HTTP_PERSISTENT_HANDLE_H
-
-typedef struct php_http_persistent_handle_factory {
-       void *provider;
-
-       struct {
-               char *str;
-               size_t len;
-       } ident;
-
-       unsigned free_on_abandon:1;
-} php_http_persistent_handle_factory_t;
-
-struct php_http_persistent_handle_globals {
-       ulong limit;
-       struct {
-               ulong h;
-               char *s;
-               size_t l;
-       } ident;
-};
-
-PHP_MINIT_FUNCTION(http_persistent_handle);
-PHP_MSHUTDOWN_FUNCTION(http_persistent_handle);
-
-PHP_HTTP_API STATUS php_http_persistent_handle_provide(const char *name_str, size_t name_len, php_http_resource_factory_ops_t *fops, void *data, void (*dtor)(void *));
-PHP_HTTP_API php_http_persistent_handle_factory_t *php_http_persistent_handle_concede(php_http_persistent_handle_factory_t *a, const char *name_str, size_t name_len, const char *ident_str, size_t ident_len TSRMLS_DC);
-PHP_HTTP_API void php_http_persistent_handle_abandon(php_http_persistent_handle_factory_t *a);
-PHP_HTTP_API void *php_http_persistent_handle_acquire(php_http_persistent_handle_factory_t *a TSRMLS_DC);
-PHP_HTTP_API void php_http_persistent_handle_release(php_http_persistent_handle_factory_t *a, void *handle TSRMLS_DC);
-PHP_HTTP_API void *php_http_persistent_handle_accrete(php_http_persistent_handle_factory_t *a, void *handle TSRMLS_DC);
-
-PHP_HTTP_API php_http_resource_factory_ops_t *php_http_persistent_handle_resource_factory_ops(void);
-
-PHP_HTTP_API void php_http_persistent_handle_cleanup(const char *name_str, size_t name_len, const char *ident_str, size_t ident_len TSRMLS_DC);
-PHP_HTTP_API HashTable *php_http_persistent_handle_statall(HashTable *ht TSRMLS_DC);
-
-#endif /* PHP_HTTP_PERSISTENT_HANDLE_H */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/php_http_resource_factory.c b/php_http_resource_factory.c
deleted file mode 100644 (file)
index 0813755..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
-    +--------------------------------------------------------------------+
-    | PECL :: http                                                       |
-    +--------------------------------------------------------------------+
-    | Redistribution and use in source and binary forms, with or without |
-    | modification, are permitted provided that the conditions mentioned |
-    | in the accompanying LICENSE file are met.                          |
-    +--------------------------------------------------------------------+
-    | Copyright (c) 2004-2011, Michael Wallner <mike@php.net>            |
-    +--------------------------------------------------------------------+
-*/
-
-#include "php_http_api.h"
-
-PHP_HTTP_API php_http_resource_factory_t *php_http_resource_factory_init(php_http_resource_factory_t *f, php_http_resource_factory_ops_t *fops, void *data, void (*dtor)(void *data))
-{
-       if (!f) {
-               f = emalloc(sizeof(*f));
-       }
-       memset(f, 0, sizeof(*f));
-
-       memcpy(&f->fops, fops, sizeof(*fops));
-
-       f->data = data;
-       f->dtor = dtor;
-
-       f->refcount = 1;
-
-       return f;
-}
-
-PHP_HTTP_API unsigned php_http_resource_factory_addref(php_http_resource_factory_t *rf)
-{
-       return ++rf->refcount;
-}
-
-PHP_HTTP_API void php_http_resource_factory_dtor(php_http_resource_factory_t *f)
-{
-       --f->refcount;
-
-       if (!f->refcount) {
-               if (f->dtor) {
-                       f->dtor(f->data);
-               }
-       }
-}
-
-PHP_HTTP_API void php_http_resource_factory_free(php_http_resource_factory_t **f)
-{
-       if (*f) {
-               php_http_resource_factory_dtor(*f);
-               if (!(*f)->refcount) {
-                       efree(*f);
-                       *f = NULL;
-               }
-       }
-}
-
-PHP_HTTP_API void *php_http_resource_factory_handle_ctor(php_http_resource_factory_t *f TSRMLS_DC)
-{
-       if (f->fops.ctor) {
-               return f->fops.ctor(f->data TSRMLS_CC);
-       }
-       return NULL;
-}
-
-PHP_HTTP_API void *php_http_resource_factory_handle_copy(php_http_resource_factory_t *f, void *handle TSRMLS_DC)
-{
-       if (f->fops.copy) {
-               return f->fops.copy(f->data, handle TSRMLS_CC);
-       }
-       return NULL;
-}
-
-PHP_HTTP_API void php_http_resource_factory_handle_dtor(php_http_resource_factory_t *f, void *handle TSRMLS_DC)
-{
-       if (f->fops.dtor) {
-               f->fops.dtor(f->data, handle TSRMLS_CC);
-       }
-}
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
-
diff --git a/php_http_resource_factory.h b/php_http_resource_factory.h
deleted file mode 100644 (file)
index 54de8c7..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
-    +--------------------------------------------------------------------+
-    | PECL :: http                                                       |
-    +--------------------------------------------------------------------+
-    | Redistribution and use in source and binary forms, with or without |
-    | modification, are permitted provided that the conditions mentioned |
-    | in the accompanying LICENSE file are met.                          |
-    +--------------------------------------------------------------------+
-    | Copyright (c) 2004-2011, Michael Wallner <mike@php.net>            |
-    +--------------------------------------------------------------------+
-*/
-
-#ifndef PHP_HTTP_RESOURCE_FACTORY_H
-#define PHP_HTTP_RESOURCE_FACTORY_H
-
-typedef void *(*php_http_resource_factory_handle_ctor_t)(void *opaque TSRMLS_DC);
-typedef void *(*php_http_resource_factory_handle_copy_t)(void *opaque, void *handle TSRMLS_DC);
-typedef void (*php_http_resource_factory_handle_dtor_t)(void *opaque, void *handle TSRMLS_DC);
-
-typedef struct php_http_resource_factory_ops {
-       php_http_resource_factory_handle_ctor_t ctor;
-       php_http_resource_factory_handle_copy_t copy;
-       php_http_resource_factory_handle_dtor_t dtor;
-} php_http_resource_factory_ops_t;
-
-typedef struct php_http_resource_factory {
-       php_http_resource_factory_ops_t fops;
-
-       void *data;
-       void (*dtor)(void *data);
-
-       unsigned refcount;
-} php_http_resource_factory_t;
-
-PHP_HTTP_API php_http_resource_factory_t *php_http_resource_factory_init(php_http_resource_factory_t *f, php_http_resource_factory_ops_t *fops, void *data, void (*dtor)(void *data));
-PHP_HTTP_API unsigned php_http_resource_factory_addref(php_http_resource_factory_t *rf);
-PHP_HTTP_API void php_http_resource_factory_dtor(php_http_resource_factory_t *f);
-PHP_HTTP_API void php_http_resource_factory_free(php_http_resource_factory_t **f);
-
-PHP_HTTP_API void *php_http_resource_factory_handle_ctor(php_http_resource_factory_t *f TSRMLS_DC);
-PHP_HTTP_API void *php_http_resource_factory_handle_copy(php_http_resource_factory_t *f, void *handle TSRMLS_DC);
-PHP_HTTP_API void php_http_resource_factory_handle_dtor(php_http_resource_factory_t *f, void *handle TSRMLS_DC);
-
-#endif /* PHP_HTTP_RESOURCE_FACTORY_H */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/tests/persistenthandles001.phpt b/tests/persistenthandles001.phpt
deleted file mode 100644 (file)
index 18bce8a..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
---TEST--
-persistent handles
---SKIPIF--
-<?php include "skipif.inc"; ?>
---FILE--
-<?php
-$f = new http\Client\Factory(array("persistentHandleId" => "foo"));
-$r = $f->createClient()->setRequest(new http\Client\Request("GET", "http://dev.iworks.at"))
-    ->setOptions(array("connecttimeout"=> 90, "timeout" =>300))
-    ->send(null);
-$f = new http\Client\Factory(array("persistentHandleId" => "bar"));
-$r = $f->createClient()->setRequest(new http\Client\Request("GET", "http://dev.iworks.at"))
-    ->setOptions(array("connecttimeout"=> 90, "timeout" =>300));
-    
-var_dump(http\Env::statPersistentHandles()); 
-http\Env::cleanPersistentHandles(); 
-var_dump(http\Env::statPersistentHandles());
-
-$r->send(null);
-
-var_dump(http\Env::statPersistentHandles());
-?>
-DONE
---EXPECTF--
-object(stdClass)#%d (3) {
-  ["http_client.curl"]=>
-  array(2) {
-    ["foo"]=>
-    array(2) {
-      ["used"]=>
-      int(0)
-      ["free"]=>
-      int(1)
-    }
-    ["bar"]=>
-    array(2) {
-      ["used"]=>
-      int(1)
-      ["free"]=>
-      int(0)
-    }
-  }
-  ["http_client_pool.curl"]=>
-  array(0) {
-  }
-  ["http_client_datashare.curl"]=>
-  array(0) {
-  }
-}
-object(stdClass)#%d (3) {
-  ["http_client.curl"]=>
-  array(1) {
-    ["bar"]=>
-    array(2) {
-      ["used"]=>
-      int(1)
-      ["free"]=>
-      int(0)
-    }
-  }
-  ["http_client_pool.curl"]=>
-  array(0) {
-  }
-  ["http_client_datashare.curl"]=>
-  array(0) {
-  }
-}
-object(stdClass)#%d (3) {
-  ["http_client.curl"]=>
-  array(1) {
-    ["bar"]=>
-    array(2) {
-      ["used"]=>
-      int(1)
-      ["free"]=>
-      int(0)
-    }
-  }
-  ["http_client_pool.curl"]=>
-  array(0) {
-  }
-  ["http_client_datashare.curl"]=>
-  array(0) {
-  }
-}
-DONE
index 22f41e5..087923e 100644 (file)
@@ -5,6 +5,8 @@ unit tests
 include "skipif.inc";
 if (!@include_once "PHPUnit/Autoload.php") die("skip need PHPUnit in include_path");
 ?>
+--INI--
+date.timezone=Europe/Vienna
 --FILE--
 <?php
 require_once "PHPUnit/Autoload.php";