From 6f6b93da02019141812b81bfdbb6bcda430c3b4d Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 26 Jul 2006 22:19:42 +0000 Subject: [Hiper-related work] Added a function called curl_multi_assign() that will set a private pointer added to the internal libcurl hash table for the particular socket passed in to this function. --- lib/multi.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'lib/multi.c') diff --git a/lib/multi.c b/lib/multi.c index 44c742476..3296f09e5 100644 --- a/lib/multi.c +++ b/lib/multi.c @@ -182,7 +182,7 @@ struct Curl_sh_entry { time_t timestamp; long inuse; int action; /* what action READ/WRITE this socket waits for */ - void *userp; /* settable by users (not yet decided exactly how) */ + void *socketp; /* settable by users with curl_multi_assign() */ }; /* bits for 'action' having no bits means this socket is not expecting any action */ @@ -1125,10 +1125,14 @@ static void singlesocket(struct Curl_multi *multi, /* call the callback with this new info */ if(multi->socket_cb) { + struct Curl_sh_entry *entry = + Curl_hash_pick(multi->sockhash, (char *)&s, sizeof(s)); + multi->socket_cb(easy->easy_handle, s, action, - multi->socket_userp); + multi->socket_userp, + entry->socketp); } /* Update the sockhash accordingly */ @@ -1385,3 +1389,19 @@ void Curl_expire(struct SessionHandle *data, long milli) #endif } +CURLMcode curl_multi_assign(CURLM *multi_handle, + curl_socket_t s, void *hashp) +{ + struct Curl_sh_entry *there = NULL; + struct Curl_multi *multi = (struct Curl_multi *)multi_handle; + + if(s != CURL_SOCKET_BAD) + there = Curl_hash_pick(multi->sockhash, (char *)&s, sizeof(curl_socket_t)); + + if(!there) + return CURLM_BAD_SOCKET; + + there->socketp = hashp; + + return CURLM_OK; +} -- cgit v1.2.3