From: Michael Wallner Date: Tue, 18 Oct 2005 11:18:33 +0000 (+0000) Subject: - use object_handlers->add_ref() X-Git-Tag: RELEASE_0_16_0~3 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=f1df16d07b48a2561ec8c3065e094f3f17c09889;p=m6w6%2Fext-http - use object_handlers->add_ref() --- diff --git a/http_message_object.c b/http_message_object.c index 561b350..ffc81ec 100644 --- a/http_message_object.c +++ b/http_message_object.c @@ -374,13 +374,15 @@ static void _http_message_object_write_prop(zval *object, zval *member, zval *va break; case HTTP_MSG_PROPHASH_PARENT_MESSAGE: - if (msg->parent) { - zval tmp; - tmp.value.obj = obj->parent; - zend_objects_store_del_ref(&tmp TSRMLS_CC); + if (Z_TYPE_P(value) == IS_OBJECT && instanceof_function(Z_OBJCE_P(value), http_message_object_ce TSRMLS_CC)) { + if (msg->parent) { + zval tmp; + tmp.value.obj = obj->parent; + Z_OBJ_DELREF(tmp); + } + Z_OBJ_ADDREF_P(value); + obj->parent = value->value.obj; } - zend_objects_store_add_ref(value TSRMLS_CC); - obj->parent = value->value.obj; break; case HTTP_MSG_PROPHASH_REQUEST_METHOD: diff --git a/http_request_pool_api.c b/http_request_pool_api.c index f557494..d8aae7c 100644 --- a/http_request_pool_api.c +++ b/http_request_pool_api.c @@ -106,7 +106,7 @@ PHP_HTTP_API STATUS _http_request_pool_attach(http_request_pool *pool, zval *req zend_llist_add_element(&pool->bodies, &body); zval_add_ref(&request); - zend_objects_store_add_ref(request TSRMLS_CC); + Z_OBJ_ADDREF_P(request); #if HTTP_DEBUG_REQPOOLS fprintf(stderr, "> %d HttpRequests attached to pool %p\n", zend_llist_count(&pool->handles), pool); @@ -305,7 +305,7 @@ void _http_request_pool_responsehandler(zval **req, CURL *ch TSRMLS_DC) #endif zval_add_ref(req); - zend_objects_store_add_ref(*req TSRMLS_CC); + Z_OBJ_ADDREF_PP(req); zend_llist_add_element(&obj->pool->finished, req); http_request_object_responsehandler(obj, *req); } diff --git a/http_requestpool_object.c b/http_requestpool_object.c index f9f463c..c0ae135 100644 --- a/http_requestpool_object.c +++ b/http_requestpool_object.c @@ -71,10 +71,6 @@ HTTP_EMPTY_ARGS(rewind, 0); HTTP_EMPTY_ARGS(getAttachedRequests, 0); HTTP_EMPTY_ARGS(getFinishedRequests, 0); -HTTP_BEGIN_ARGS(setRequestOptions, 0) - HTTP_ARG_VAL(options, 0) -HTTP_END_ARGS; - #define http_requestpool_object_declare_default_properties() _http_requestpool_object_declare_default_properties(TSRMLS_C) static inline void _http_requestpool_object_declare_default_properties(TSRMLS_D); @@ -154,7 +150,7 @@ void _http_requestpool_object_free(zend_object *object TSRMLS_DC) static void _http_requestpool_object_llist2array(zval **req, zval *array TSRMLS_DC) { zval_add_ref(req); - zend_objects_store_add_ref(*req TSRMLS_CC); + Z_OBJ_ADDREF_PP(req); add_next_index_zval(array, *req); } @@ -471,6 +467,12 @@ PHP_METHOD(HttpRequestPool, rewind) } /* }}} */ +/* {{{ proto array HttpRequestPool::getAttachedRequests() + * + * Get attached HttpRequest objects. + * + * Returns an array containing all currently attached HttpRequest objects. + */ PHP_METHOD(HttpRequestPool, getAttachedRequests) { getObject(http_requestpool_object, obj); @@ -482,7 +484,15 @@ PHP_METHOD(HttpRequestPool, getAttachedRequests) (llist_apply_with_arg_func_t) http_requestpool_object_llist2array, return_value TSRMLS_CC); } +/* }}} */ +/* {{{ proto array HttpRequestPool::getFinishedRequests() + * + * Get attached HttpRequest objects that already have finished their work. + * + * Returns an array containing all attached HttpRequest objects that + * already have finished their work. + */ PHP_METHOD(HttpRequestPool, getFinishedRequests) { getObject(http_requestpool_object, obj); @@ -494,6 +504,7 @@ PHP_METHOD(HttpRequestPool, getFinishedRequests) (llist_apply_with_arg_func_t) http_requestpool_object_llist2array, return_value TSRMLS_CC); } +/* }}} */ #endif /* ZEND_ENGINE_2 && HTTP_HAVE_CURL */ diff --git a/php_http_std_defs.h b/php_http_std_defs.h index 4f9f93e..a8289fd 100644 --- a/php_http_std_defs.h +++ b/php_http_std_defs.h @@ -421,6 +421,31 @@ typedef int STATUS; #define PHP_MSHUTDOWN_CALL(func) PHP_MSHUTDOWN(func)(SHUTDOWN_FUNC_ARGS_PASSTHRU) #define PHP_RSHUTDOWN_CALL(func) PHP_RSHUTDOWN(func)(SHUTDOWN_FUNC_ARGS_PASSTHRU) +#define Z_OBJ_DELREF(z) \ + if (Z_OBJ_HT(z)->del_ref) { \ + Z_OBJ_HT(z)->del_ref(&(z) TSRMLS_CC); \ + } +#define Z_OBJ_ADDREF(z) \ + if (Z_OBJ_HT(z)->add_ref) { \ + Z_OBJ_HT(z)->add_ref(&(z) TSRMLS_CC); \ + } +#define Z_OBJ_DELREF_P(z) \ + if (Z_OBJ_HT_P(z)->del_ref) { \ + Z_OBJ_HT_P(z)->del_ref((z) TSRMLS_CC); \ + } +#define Z_OBJ_ADDREF_P(z) \ + if (Z_OBJ_HT_P(z)->add_ref) { \ + Z_OBJ_HT_P(z)->add_ref((z) TSRMLS_CC); \ + } +#define Z_OBJ_DELREF_PP(z) \ + if (Z_OBJ_HT_PP(z)->del_ref) { \ + Z_OBJ_HT_PP(z)->del_ref(*(z) TSRMLS_CC); \ + } +#define Z_OBJ_ADDREF_PP(z) \ + if (Z_OBJ_HT_PP(z)->add_ref) { \ + Z_OBJ_HT_PP(z)->add_ref(*(z) TSRMLS_CC); \ + } + #endif /* PHP_HTTP_STD_DEFS_H */ /*