>Number: 159352 >Category: bin >Synopsis: accidental busy-waiting loop in fetch(3) >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Aug 01 12:10:05 UTC 2011 >Closed-Date: >Last-Modified: >Originator: Mathieu >Release: 8.2-STABLE >Organization: >Environment: 8.2-STABLE FreeBSD 8.2-STABLE #0 r223938M >Description: Sometimes, fetch(1) will use 100% CPU time while downloading. There's a loop that will retry I/O syscalls that returned EAGAIN immediately without blocking due to a small bug.
>How-To-Repeat: Probably only noticeable on slow links. >Fix: Index: common.c =================================================================== --- common.c (revision 223938) +++ common.c (working copy) @@ -429,12 +429,6 @@ ssize_t rlen, total; int r; - if (fetchTimeout) { - FD_ZERO(&readfds); - gettimeofday(&timeout, NULL); - timeout.tv_sec += fetchTimeout; - } - total = 0; while (len > 0) { /* @@ -474,6 +468,11 @@ return (-1); } // assert(rlen == FETCH_READ_WAIT); + if (fetchTimeout) { + FD_ZERO(&readfds); + gettimeofday(&timeout, NULL); + timeout.tv_sec += fetchTimeout; + } while (fetchTimeout && !FD_ISSET(conn->sd, &readfds)) { FD_SET(conn->sd, &readfds); gettimeofday(&now, NULL); @@ -576,14 +575,13 @@ ssize_t wlen, total; int r; - if (fetchTimeout) { - FD_ZERO(&writefds); - gettimeofday(&timeout, NULL); - timeout.tv_sec += fetchTimeout; - } - total = 0; while (iovcnt > 0) { + if (fetchTimeout) { + FD_ZERO(&writefds); + gettimeofday(&timeout, NULL); + timeout.tv_sec += fetchTimeout; + } while (fetchTimeout && !FD_ISSET(conn->sd, &writefds)) { FD_SET(conn->sd, &writefds); gettimeofday(&now, NULL); >Release-Note: >Audit-Trail: >Unformatted: _______________________________________________ freebsd-bugs@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-bugs To unsubscribe, send any mail to "freebsd-bugs-unsubscr...@freebsd.org"