From 6b2fbc41bc4b5e3f4af63f640779be79c414ce65 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 15 May 2003 21:25:34 +0000 Subject: [PATCH] Win network kludge svn path=/trunk/boinc/; revision=1208 --- client/net_xfer.C | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/client/net_xfer.C b/client/net_xfer.C index f8018d0f10..238f70d2f4 100644 --- a/client/net_xfer.C +++ b/client/net_xfer.C @@ -249,6 +249,7 @@ bool NET_XFER_SET::poll() { // Wait at most x seconds for network I/O to become possible, // then do up to about .5 seconds of I/O. +// This is used only by the cmdline client, to sleep without slowing down I/O. // int NET_XFER_SET::net_sleep(double x) { int retval; @@ -281,6 +282,8 @@ int NET_XFER_SET::do_select(double& bytes_transferred, timeval& timeout) { socklen_t intsize = sizeof(int); #endif + // if a second has gone by, do rate-limit accounting + // time_t t = time(0); if (t != last_time) { last_time = t; @@ -314,6 +317,21 @@ int NET_XFER_SET::do_select(double& bytes_transferred, timeval& timeout) { } } else if (nxp->want_upload) { if (bytes_left_up > 0) { +#ifdef _WIN32 + // KLUDGE ALERT!!!!! + // In the Windows GUI version we rely on the WSAAsynchSelect + // mechanism to send us a message when I/O becomes possible. + // But apparently this message is sent only if you've already + // done a send() that failed because of full buffer. + // So do this send here, even though it's overkill + // + retval = nxp->do_xfer(n); + nxp->update_speed(n); + bytes_transferred += n; + up_active = true; + bytes_left_up -= n; + bytes_up += n; +#endif FD_SET(nxp->socket, &write_fds); } else { if (log_flags.net_xfer_debug) printf("Throttling upload\n"); @@ -398,7 +416,7 @@ NET_XFER* NET_XFER_SET::lookup_fd(int fd) { // transfer up to a block of data; return #bytes transferred // int NET_XFER::do_xfer(int& nbytes_transferred) { - int n, m, nleft; + unsigned int n, m, nleft; bool would_block; char buf[MAX_BLOCKSIZE]; @@ -470,8 +488,9 @@ int NET_XFER::do_xfer(int& nbytes_transferred) { nbytes_transferred += n; bytes_xferred += n; - if (n < nleft || would_block) + if (n < nleft || would_block) { break; + } nleft -= n; }