From b0053587ed994c65fc195d8e3afcc0b1597a0f42 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 15 May 2003 18:05:24 +0000 Subject: [PATCH] net_sleep does more than one block of I/O svn path=/trunk/boinc/; revision=1206 --- checkin_notes | 7 +++++++ client/net_xfer.C | 17 +++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/checkin_notes b/checkin_notes index 4f02190740..0e6a71bc1b 100755 --- a/checkin_notes +++ b/checkin_notes @@ -4172,3 +4172,10 @@ Erik May 15 2003 util.C doc/ client.html + +Erik May 15 2003 + - change NET_XFER::net_sleep() so that it does up to about .5 sec of I/O, + rather than just one block per socket + + client/ + net_xfer.C diff --git a/client/net_xfer.C b/client/net_xfer.C index c815626fad..2a8c1d928a 100644 --- a/client/net_xfer.C +++ b/client/net_xfer.C @@ -225,8 +225,8 @@ int NET_XFER_SET::remove(NET_XFER* nxp) { return 1; } -// Transfer data to/from active streams -// Nonblocking; keep doing I/O until would block, or we hit rate limits, +// Transfer data to/from active sockets. +// Keep doing I/O until would block, or we hit rate limits, // or about .5 second goes by // bool NET_XFER_SET::poll() { @@ -248,7 +248,7 @@ bool NET_XFER_SET::poll() { } // Wait at most x seconds for network I/O to become possible, -// then do a limited amount (one block per socket) of it. +// then do up to about .5 seconds of I/O. // int NET_XFER_SET::net_sleep(double x) { int retval; @@ -258,11 +258,16 @@ int NET_XFER_SET::net_sleep(double x) { timeout.tv_sec = (int)x; timeout.tv_usec = (int)(1000000*(x - (int)x)); retval = do_select(bytes_xferred, timeout); - return retval; + if (retval) return retval; + if (bytes_xferred) { + return poll(); + } + return 0; } -// do a select and do I/O on as many sockets as possible, -// subject to rate limits +// do a select with the given timeout, +// then do I/O on as many sockets as possible, subject to rate limits +// Transfer at most one block per socket. // int NET_XFER_SET::do_select(double& bytes_transferred, timeval& timeout) { int n, fd, retval;