curl-library
Re: [PATCH RFC] curl_multi_remove_handle() optimization
Date: Thu, 29 Mar 2007 16:25:32 +0200
On 3/29/07, Daniel Stenberg <daniel_at_haxx.se> wrote:
> On Tue, 27 Mar 2007, Robert Iakobashvili wrote:
>
> > 7.16.1 and snapshot 7.16.2-20070326
>
> Really? I just tried it against the current CVS tree and it seems to object:
> Can you attach a resynced version?
Something was wrong.
Please, find inlined as well as attached.
---------------------------------------------------------
diff -Naru curl-7.16.2-20070326/lib/multi.c curl-7.16.2-20070326-mod/lib/multi.c
--- curl-7.16.2-20070326/lib/multi.c 2007-03-26 04:00:02.000000000 +0200
+++ curl-7.16.2-20070326-mod/lib/multi.c 2007-03-29 20:00:24.000000000 +0200
@@ -413,6 +413,9 @@
easy->easy_handle = easy_handle;
multistate(easy, CURLM_STATE_INIT);
+ /* set the back pointer to one_easy to assist in removal */
+ easy->easy_handle->multi_pos = easy;
+
/* for multi interface connections, we share DNS cache automatically if the
easy handle's one is currently private. */
if (easy->easy_handle->dns.hostcache &&
@@ -516,13 +519,8 @@
if(!GOOD_EASY_HANDLE(curl_handle))
return CURLM_BAD_EASY_HANDLE;
- /* scan through the list and remove the 'curl_handle' */
- easy = multi->easy.next;
- while(easy != &multi->easy) {
- if(easy->easy_handle == (struct SessionHandle *)curl_handle)
- break;
- easy=easy->next;
- }
+ /* pick-up from the 'curl_handle' the kept position in the list */
+ easy = ((struct SessionHandle *)curl_handle)->multi_pos;
if(easy) {
bool premature = (bool)(easy->state != CURLM_STATE_COMPLETED);
@@ -626,6 +624,10 @@
easy->easy_handle->set.one_easy = NULL; /* detached */
+ /* Null the position in the controlling structure */
+ ((struct SessionHandle *)curl_handle)->multi_pos = NULL;
+
+
/* NOTE NOTE NOTE
We do not touch the easy handle here! */
if (easy->msg)
diff -Naru curl-7.16.2-20070326/lib/urldata.h
curl-7.16.2-20070326-mod/lib/urldata.h
--- curl-7.16.2-20070326/lib/urldata.h 2007-02-26 05:00:14.000000000 +0200
+++ curl-7.16.2-20070326-mod/lib/urldata.h 2007-03-29 19:57:28.000000000 +0200
@@ -1342,6 +1342,8 @@
struct Names dns;
struct Curl_multi *multi; /* if non-NULL, points to the multi handle
struct to which this "belongs" */
+ struct Curl_one_easy *multi_pos; /* if non-NULL, points to the its position
+ in multi controlling structure
to assist in removal. */
struct Curl_share *share; /* Share, handles global variable mutexing */
struct HandleData reqdata; /* Request-specific data */
struct UserDefined set; /* values set by the libcurl user */
-----------------------------------------------------------------------------------------------
-- Sincerely, Robert Iakobashvili, coroberti %x40 gmail %x2e com ................................................................... Navigare necesse est, vivere non est necesse ................................................................... http://curl-loader.sourceforge.net A powerful open-source HTTP/S, FTP/S traffic generating, loading and testing tool.
- text/x-patch attachment: curl-remove-handle-fr-multi-7.16.2-20070326.patch