[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.
This commit is contained in:
Daniel Stenberg
2006-07-26 22:19:42 +00:00
parent 45b1843dc9
commit 6f6b93da02
10 changed files with 204 additions and 81 deletions

View File

@@ -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;
}