curl-library
Modification of curl_multi_fdset()
Date: Fri, 6 Jun 2008 22:21:05 +0300
Hello Daniel,
We use libcurl in a project and have some issues with
curl_multi_fdset() function:
1) curl_multi_fdset does not fill exc_fd_set.
2) we need to know if there is any fd in write_fd_set,
returned from curl_multi_fdset.
I modified curl_multi_fdset() so now it fills only
fd_sets which are not NULL. It resolves both issues
and does not break previous behavior.
Could you please insert these changes into libcurl sources?
Thanks,
Alexey
diff -u -r1.172 multi.c
--- multi.c 28 May 2008 20:56:19 -0000 1.172
+++ multi.c 6 Jun 2008 19:10:41 -0000
@@ -826,7 +826,6 @@
curl_socket_t sockbunch[MAX_SOCKSPEREASYHANDLE];
int bitmap;
int i;
- (void)exc_fd_set; /* not used */
if(!GOOD_MULTI_HANDLE(multi))
return CURLM_BAD_HANDLE;
@@ -836,29 +835,40 @@
bitmap = multi_getsock(easy, sockbunch, MAX_SOCKSPEREASYHANDLE);
for(i=0; i< MAX_SOCKSPEREASYHANDLE; i++) {
+ int added = 0;
curl_socket_t s = CURL_SOCKET_BAD;
if(bitmap & GETSOCK_READSOCK(i)) {
- FD_SET(sockbunch[i], read_fd_set);
+ if(read_fd_set){
+ FD_SET(sockbunch[i], read_fd_set);
+ added = 1;
+ }
s = sockbunch[i];
}
if(bitmap & GETSOCK_WRITESOCK(i)) {
- FD_SET(sockbunch[i], write_fd_set);
+ if(write_fd_set) {
+ FD_SET(sockbunch[i], write_fd_set);
+ added = 1;
+ }
s = sockbunch[i];
}
if(s == CURL_SOCKET_BAD)
/* this socket is unused, break out of loop */
break;
- else {
- if((int)s > this_max_fd)
+ else if(added) {
+ if((INT)s > this_max_fd)
this_max_fd = (int)s;
+
+ if(exc_fd_set)
+ FD_SET(s, exc_fd_set);
}
}
easy = easy->next; /* check next handle */
}
- *max_fd = this_max_fd;
+ if(max_fd)
+ *max_fd = this_max_fd;
return CURLM_OK;
}
Received on 2008-06-06