#include <Zend/zend_interfaces.h>
#include <ext/spl/spl_iterators.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, void *init_arg TSRMLS_DC)
+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;
memset(h, 0, sizeof(*h));
h->ops = ops;
+ h->rf = rf ? rf : php_http_resource_factory_init(NULL, h->ops->rsrc, NULL, NULL TSRMLS_CC);
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);
zend_llist_clean(&h->requests.finished);
zend_llist_clean(&h->requests.attached);
+
+ if (h->persistent_handle_id) {
+ zval_ptr_dtor(&h->persistent_handle_id);
+ }
}
PHP_HTTP_API void php_http_request_pool_free(php_http_request_pool_t **h) {
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) {
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();
}
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)) {
{
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;
{
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);