aboutsummaryrefslogtreecommitdiff
path: root/lib/transfer.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2006-04-10 15:00:53 +0000
committerDaniel Stenberg <daniel@haxx.se>2006-04-10 15:00:53 +0000
commit686d90745be4417127050ad4b36d0a5403def200 (patch)
tree786a63b7554065aa0514440adf35fd7b639ae94c /lib/transfer.c
parent5dc02d53c3edebab7597cd4ada446273e3a6daa8 (diff)
First curl_multi_socket() commit. Should primarily be considered as an internal
code rearrange to fit the future better.
Diffstat (limited to 'lib/transfer.c')
-rw-r--r--lib/transfer.c45
1 files changed, 27 insertions, 18 deletions
diff --git a/lib/transfer.c b/lib/transfer.c
index 6bd2dc904..6e4fe4c71 100644
--- a/lib/transfer.c
+++ b/lib/transfer.c
@@ -101,6 +101,7 @@
#include "share.h"
#include "memory.h"
#include "select.h"
+#include "multiif.h"
#include "easyif.h" /* for Curl_convert_to_network prototype */
#define _MPRINTF_REPLACE /* use our functions only */
@@ -1522,34 +1523,42 @@ CURLcode Curl_readwrite_init(struct connectdata *conn)
}
/*
- * Curl_single_fdset() gets called by the multi interface code when the app
- * has requested to get the fd_sets for the current connection. This function
+ * Curl_single_getsock() gets called by the multi interface code when the app
+ * has requested to get the sockets for the current connection. This function
* will then be called once for every connection that the multi interface
* keeps track of. This function will only be called for connections that are
* in the proper state to have this information available.
*/
-void Curl_single_fdset(struct connectdata *conn,
- fd_set *read_fd_set,
- fd_set *write_fd_set,
- fd_set *exc_fd_set,
- int *max_fd)
+int Curl_single_getsock(struct connectdata *conn,
+ curl_socket_t *sock, /* points to numsocks number
+ of sockets */
+ int numsocks)
{
- *max_fd = -1; /* init */
+ int bitmap = GETSOCK_BLANK;
+ int index = 0;
+
+ if(numsocks < 2)
+ /* simple check but we might need two slots */
+ return GETSOCK_BLANK;
+
if(conn->keep.keepon & KEEP_READ) {
- FD_SET(conn->sockfd, read_fd_set);
- *max_fd = (int)conn->sockfd;
+ bitmap |= GETSOCK_READSOCK(index);
+ sock[index] = conn->sockfd;
}
if(conn->keep.keepon & KEEP_WRITE) {
- FD_SET(conn->writesockfd, write_fd_set);
- /* since sockets are curl_socket_t nowadays, we typecast it to int here
- to compare it nicely */
- if((int)conn->writesockfd > *max_fd)
- *max_fd = (int)conn->writesockfd;
+ if((conn->sockfd != conn->writesockfd) &&
+ (conn->keep.keepon & KEEP_READ)) {
+ /* only if they are not the same socket and we had a readable one,
+ we increase index */
+ index++;
+ sock[index] = conn->writesockfd;
+ }
+
+ bitmap |= GETSOCK_WRITESOCK(index);
}
- /* we don't use exceptions, only touch that one to prevent compiler
- warnings! */
- *exc_fd_set = *exc_fd_set;
+
+ return bitmap;
}