Skip to content

Commit

Permalink
Add curl_multi_fdvec() method
Browse files Browse the repository at this point in the history
  • Loading branch information
sgolemon committed Jul 14, 2012
1 parent 3649aee commit 0ea58d1
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
12 changes: 12 additions & 0 deletions include/curl/multi.h
Expand Up @@ -148,6 +148,18 @@ CURL_EXTERN CURLMcode curl_multi_fdset(CURLM *multi_handle,
fd_set *exc_fd_set,
int *max_fd);

/*
* Name: curl_multi_fdvec()
*
* Desc: Retreive a vector of fds contained in the multi handle
*
* Returns: CURLMcode type, general multi error code.
*/
CURL_EXTERN CURLMcode curl_multi_fdvec(CURLM *multi_handle,
int *read_fds,
int *write_fds,
int *ex_fds);

/*
* Name: curl_multi_perform()
*
Expand Down
32 changes: 32 additions & 0 deletions lib/multi.c
Expand Up @@ -941,6 +941,38 @@ CURLMcode curl_multi_fdset(CURLM *multi_handle,
return CURLM_OK;
}

CURLMcode curl_multi_fdvec(CURLM *multi_handle,
int *read_fds,
int *write_fds,
int *ex_fds)
{
struct Curl_multi *multi=(struct Curl_multi *)multi_handle;
struct Curl_one_easy *easy;
int rfds = 0, wfds = 0, xfds = 0;
(void)ex_fds; /* not used */

if(!GOOD_MULTI_HANDLE(multi))
return CURLM_BAD_HANDLE;

for(easy = multi->easy.next;
easy != &multi->easy;
easy = easy->next) {
curl_socket_t sockbunch[MAX_SOCKSPEREASYHANDLE];
int i, bitmap = multi_getsock(easy, sockbunch, MAX_SOCKSPEREASYHANDLE);

for(i=0; i< MAX_SOCKSPEREASYHANDLE; i++) {
if (read_fds && (bitmap & GETSOCK_READSOCK(i))) {
read_fds[rfds++] = sockbunch[i];
}
if (write_fds && (bitmap & GETSOCK_WRITESOCK(i))) {
write_fds[wfds++] = sockbunch[i];
}
}
}

return CURLM_OK;
}

static CURLMcode multi_runsingle(struct Curl_multi *multi,
struct timeval now,
struct Curl_one_easy *easy)
Expand Down

0 comments on commit 0ea58d1

Please sign in to comment.