X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=php_http_request_pool.c;h=2cf70efbc19fcd785af1be24d253f879e0f7a447;hp=7f081b82080e9c777f96fc18d19b32f385b9452b;hb=14aec371d6123fbedbe13ca73b6a6d5768c635cb;hpb=df06e2dbf48a3b0d96f2c62071c1b5fc907a98d0 diff --git a/php_http_request_pool.c b/php_http_request_pool.c index 7f081b8..2cf70ef 100644 --- a/php_http_request_pool.c +++ b/php_http_request_pool.c @@ -1,10 +1,18 @@ - -#include "php_http.h" - -#include -#include - -PHP_HTTP_API php_http_request_pool_t *php_http_request_pool_init(php_http_request_pool_t *h, php_http_request_pool_ops_t *ops, void *init_arg TSRMLS_DC) +/* + +--------------------------------------------------------------------+ + | 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 | + +--------------------------------------------------------------------+ +*/ + +#include "php_http_api.h" + +PHP_HTTP_API php_http_request_pool_t *php_http_request_pool_init(php_http_request_pool_t *h, php_http_request_pool_ops_t *ops, php_http_resource_factory_t *rf, void *init_arg TSRMLS_DC) { php_http_request_pool_t *free_h = NULL; @@ -14,6 +22,7 @@ PHP_HTTP_API php_http_request_pool_t *php_http_request_pool_init(php_http_reques memset(h, 0, sizeof(*h)); h->ops = ops; + h->rf = rf ? rf : php_http_resource_factory_init(NULL, h->ops->rsrc, NULL, NULL); zend_llist_init(&h->requests.attached, sizeof(zval *), (llist_dtor_func_t) ZVAL_PTR_DTOR, 0); zend_llist_init(&h->requests.finished, sizeof(zval *), (llist_dtor_func_t) ZVAL_PTR_DTOR, 0); TSRMLS_SET_CTX(h->ts); @@ -47,6 +56,8 @@ PHP_HTTP_API void php_http_request_pool_dtor(php_http_request_pool_t *h) zend_llist_clean(&h->requests.finished); zend_llist_clean(&h->requests.attached); + + php_http_resource_factory_free(&h->rf); } PHP_HTTP_API void php_http_request_pool_free(php_http_request_pool_t **h) { @@ -67,7 +78,7 @@ PHP_HTTP_API STATUS php_http_request_pool_attach(php_http_request_pool_t *h, zva php_http_message_body_t *body = NULL; php_http_request_object_t *obj = zend_object_store_get_object(request TSRMLS_CC); - if (SUCCESS != php_http_request_object_requesthandler(obj, request, &m, &url, &body)) { + if (SUCCESS != php_http_request_object_requesthandler(obj, request, &m, &url, &body TSRMLS_CC)) { return FAILURE; } if (SUCCESS == h->ops->attach(h, obj->request, m, url, body)) { @@ -125,8 +136,6 @@ PHP_HTTP_API int php_http_request_pool_once(php_http_request_pool_t *h) PHP_HTTP_API STATUS php_http_request_pool_exec(php_http_request_pool_t *h) { - TSRMLS_FETCH_FROM_CTX(h->ts); - if (h->ops->exec) { return h->ops->exec(h); } @@ -285,7 +294,7 @@ zend_object_value php_http_request_pool_object_new_ex(zend_class_entry *ce, php_ object_properties_init((zend_object *) o, ce); if (!(o->pool = p)) { - o->pool = php_http_request_pool_init(NULL, NULL, NULL TSRMLS_CC); + o->pool = php_http_request_pool_init(NULL, NULL, NULL, NULL TSRMLS_CC); } if (ptr) { @@ -316,7 +325,7 @@ static void php_http_request_pool_object_llist2array(zval **req, zval *array TSR PHP_METHOD(HttpRequestPool, __construct) { - with_error_handling(EH_THROW, PHP_HTTP_EX_CE(runtime)) { + with_error_handling(EH_THROW, php_http_exception_class_entry) { zend_parse_parameters_none(); } end_error_handling(); } @@ -345,11 +354,11 @@ PHP_METHOD(HttpRequestPool, reset) PHP_METHOD(HttpRequestPool, attach) { - with_error_handling(EH_THROW, PHP_HTTP_EX_CE(runtime)) { + with_error_handling(EH_THROW, php_http_exception_class_entry) { zval *request; if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &request, php_http_request_class_entry)) { - with_error_handling(EH_THROW, PHP_HTTP_EX_CE(runtime)) { + with_error_handling(EH_THROW, php_http_exception_class_entry) { php_http_request_pool_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC); if (obj->iterator.pos > 0 && obj->iterator.pos < zend_llist_count(&obj->pool->requests.attached)) { @@ -368,11 +377,11 @@ PHP_METHOD(HttpRequestPool, detach) { RETVAL_FALSE; - with_error_handling(EH_THROW, PHP_HTTP_EX_CE(runtime)) { + with_error_handling(EH_THROW, php_http_exception_class_entry) { zval *request; if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &request, php_http_request_class_entry)) { - with_error_handling(EH_THROW, PHP_HTTP_EX_CE(request_pool)) { + with_error_handling(EH_THROW, php_http_exception_class_entry) { php_http_request_pool_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC); obj->iterator.pos = -1; @@ -388,9 +397,9 @@ PHP_METHOD(HttpRequestPool, send) { RETVAL_FALSE; - with_error_handling(EH_THROW, PHP_HTTP_EX_CE(runtime)) { + with_error_handling(EH_THROW, php_http_exception_class_entry) { if (SUCCESS == zend_parse_parameters_none()) { - with_error_handling(EH_THROW, PHP_HTTP_EX_CE(request_pool)) { + with_error_handling(EH_THROW, php_http_exception_class_entry) { php_http_request_pool_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC); php_http_request_pool_exec(obj->pool); @@ -551,13 +560,23 @@ PHP_METHOD(HttpRequestPool, enableEvents) PHP_MINIT_FUNCTION(http_request_pool) { - PHP_HTTP_REGISTER_CLASS(http\\request, Pool, http_request_pool, php_http_object_class_entry, 0); + PHP_HTTP_REGISTER_CLASS(http\\Request, Pool, http_request_pool, php_http_object_class_entry, 0); php_http_request_pool_class_entry->create_object = php_http_request_pool_object_new; memcpy(&php_http_request_pool_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); php_http_request_pool_object_handlers.clone_obj = NULL; - zend_class_implements(php_http_request_pool_class_entry TSRMLS_CC, 3, spl_ce_Countable, zend_ce_iterator, php_http_fluently_callable_class_entry); + zend_class_implements(php_http_request_pool_class_entry TSRMLS_CC, 2, spl_ce_Countable, zend_ce_iterator); return SUCCESS; } + +/* + * 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 + */ +