- use object_handlers->add_ref()
authorMichael Wallner <mike@php.net>
Tue, 18 Oct 2005 11:18:33 +0000 (11:18 +0000)
committerMichael Wallner <mike@php.net>
Tue, 18 Oct 2005 11:18:33 +0000 (11:18 +0000)
http_message_object.c
http_request_pool_api.c
http_requestpool_object.c
php_http_std_defs.h

index 561b3508aa54003e5ad8441e8d87c2a082cb6212..ffc81ec61d773b9ecee9950c5dc33ba8d7a30c8d 100644 (file)
@@ -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:
index f5574940af4795144bf1372055d7aa3c36099b0a..d8aae7c004f8c924a7bfb962ec7855f49cad760a 100644 (file)
@@ -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);
        }
index f9f463cb0888bcb7438e3747fca167c84e89c24b..c0ae1357d3e9ca9126a11907faaff40af9c951b4 100644 (file)
@@ -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 */
 
index 4f9f93e3dc7ca513f7f331fe79a8ba5df8d46c73..a8289fdad1118a639732c3d3e40582e2f0cd751e 100644 (file)
@@ -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 */
 
 /*