From bb7c2ddb23955e9757837601b1311398cf9ac9f7 Mon Sep 17 00:00:00 2001 From: Sterling Hughes Date: Wed, 2 Apr 2003 16:58:52 +0000 Subject: [PATCH] add the ability for curl_multi_info to introspect the handles. # Zend commit doesn't break anything, so I'm committing it. If anyone # has problems, just speak up. :) --- Zend/zend_list.c | 17 +++++++++++++++++ Zend/zend_list.h | 2 ++ ext/curl/multi.c | 2 +- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Zend/zend_list.c b/Zend/zend_list.c index 348ecaf665..de3d11f265 100644 --- a/Zend/zend_list.c +++ b/Zend/zend_list.c @@ -43,6 +43,8 @@ ZEND_API int zend_list_insert(void *ptr, int type) le.refcount=1; index = zend_hash_next_free_element(&EG(regular_list)); + le.id = index; + zend_hash_index_update(&EG(regular_list), index, (void *) &le, sizeof(zend_rsrc_list_entry), NULL); return index; } @@ -77,7 +79,22 @@ ZEND_API void *_zend_list_find(int id, int *type TSRMLS_DC) } } +ZEND_API int zend_list_id_by_pointer(void *p, int type TSRMLS_DC) +{ + zend_rsrc_list_entry *le; + HashPosition pos; + for (zend_hash_internal_pointer_reset_ex(&EG(regular_list), &pos); + zend_hash_get_current_data_ex(&EG(regular_list), (void *) &le, &pos) == SUCCESS; + zend_hash_move_forward_ex(&EG(regular_list), &pos)) { + if (le->type == type && le->ptr == p) { + return le->id; + } + } + + return -1; +} + ZEND_API int _zend_list_addref(int id TSRMLS_DC) { zend_rsrc_list_entry *le; diff --git a/Zend/zend_list.h b/Zend/zend_list.h index 05f5d50bf8..c6c3b1f8f4 100644 --- a/Zend/zend_list.h +++ b/Zend/zend_list.h @@ -34,6 +34,7 @@ typedef struct _zend_rsrc_list_entry { void *ptr; int type; int refcount; + int id; } zend_rsrc_list_entry; typedef void (*rsrc_dtor_func_t)(zend_rsrc_list_entry *rsrc TSRMLS_DC); @@ -74,6 +75,7 @@ ZEND_API int zend_list_insert(void *ptr, int type); ZEND_API int _zend_list_addref(int id TSRMLS_DC); ZEND_API int _zend_list_delete(int id TSRMLS_DC); ZEND_API void *_zend_list_find(int id, int *type TSRMLS_DC); +ZEND_API int zend_list_id_by_pointer(void *p, int type TSRMLS_DC); #define zend_list_addref(id) _zend_list_addref(id TSRMLS_CC) #define zend_list_delete(id) _zend_list_delete(id TSRMLS_CC) diff --git a/ext/curl/multi.c b/ext/curl/multi.c index 19aef8f0b6..24a4df94a1 100644 --- a/ext/curl/multi.c +++ b/ext/curl/multi.c @@ -221,7 +221,7 @@ PHP_FUNCTION(curl_multi_info_read) array_init(return_value); add_assoc_long(return_value, "msg", tmp_msg->msg); add_assoc_long(return_value, "result", tmp_msg->data.result); -/* add_assoc_resource(return_value, "handle", _find_handle(tmp_msg->easy_handle)); */ + add_assoc_resource(return_value, "handle", zend_list_id_by_pointer(tmp_msg->easy_handle, le_curl TSRMLS_CC)); add_assoc_string(return_value, "whatever", (char *) tmp_msg->data.whatever, 1); } /* }}} */ -- 2.50.1