Received: by mail.netbsd.org (Postfix, from userid 605) id 41C6D84E2A; Sun, 10 Mar 2019 14:45:55 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mail.netbsd.org (Postfix) with ESMTP id 460E684E2A for ; Sun, 10 Mar 2019 14:45:54 +0000 (UTC) X-Virus-Scanned: amavisd-new at netbsd.org Received: from mail.netbsd.org ([127.0.0.1]) by localhost (mail.netbsd.org [127.0.0.1]) (amavisd-new, port 10025) with ESMTP id 7-3SyrT6bCKK for ; Sun, 10 Mar 2019 14:45:53 +0000 (UTC) Received: from cvs.NetBSD.org (ivanova.netbsd.org [199.233.217.197]) by mail.netbsd.org (Postfix) with ESMTP id 9962984D52 for ; Sun, 10 Mar 2019 14:45:53 +0000 (UTC) Received: by cvs.NetBSD.org (Postfix, from userid 500) id 930B2FB16; Sun, 10 Mar 2019 14:45:53 +0000 (UTC) Content-Disposition: inline Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" MIME-Version: 1.0 Date: Sun, 10 Mar 2019 14:45:53 +0000 From: "Robert Elz" Subject: CVS commit: src/sys/kern To: source-changes@NetBSD.org X-Mailer: log_accum Message-Id: <20190310144553.930B2FB16@cvs.NetBSD.org> Sender: source-changes-owner@NetBSD.org List-Id: source-changes.NetBSD.org Precedence: bulk Reply-To: source-changes-d@NetBSD.org Mail-Reply-To: "Robert Elz" Mail-Followup-To: source-changes-d@NetBSD.org List-Unsubscribe: Module Name: src Committed By: kre Date: Sun Mar 10 14:45:53 UTC 2019 Modified Files: src/sys/kern: kern_time.c Log Message: Fix the code that deals with very long sleeps (> 248 days) which go beyond the maximum that the callout mechanism can handle. [See the comments in tvtohz() in subr_sleep.c for the details.] When that happens the timeout is clamped to MAX_INT (ticks), and the code in nanosleep1() looped (or tried to) repeating the sleep (aka kpause()) until the requested end time for the sleep was reached. Unfortunately, the code assumed that kpause() would return 0 when it returned after the timeout expired. But it doesn't, it returns EWOULDBLOCK instead (why is incomprehensible to me, but I assume there is a reason.) [That comes from sleepq_block() which returns EWOULDBLOCK when callout_halt() indicates that the callout had fired, which is exactly what has happened when the time has elapsed.] There was already code to deal with that EWOULDBLOCK and return 0 instead of an error in that case - but it was placed after the error code was tested against 0 for the purposes of the loop. Simply move the EWOULDBLOCK->0 mapping earlier, so the code which is expecting "error == 0" to mean "nothing went wrong" actually gets to see that happen, and the loop can actually loop. (Someday the loop should probably be rewritten as a loop, instead of as a bunch of code followed by a "goto again"!) To generate a diff of this commit: cvs rdiff -u -r1.196 -r1.197 src/sys/kern/kern_time.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.