]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
upstream: In waitfd(), when poll returns early we are subtracting
authordtucker@openbsd.org <dtucker@openbsd.org>
Fri, 15 Jan 2021 02:32:41 +0000 (02:32 +0000)
committerDarren Tucker <dtucker@dtucker.net>
Mon, 18 Jan 2021 07:43:43 +0000 (18:43 +1100)
the elapsed time from the timeout each loop, so we only want to measure the
elapsed time the poll() in that loop, not since the start of the function.
Spotted by chris.xj.zhu at gmail.com, ok djm@

OpenBSD-Commit-ID: 199df060978ee9aa89b8041a3dfaf1bf7ae8dd7a

misc.c

diff --git a/misc.c b/misc.c
index a4a3f2e24f529361d5499fb95240b279789bb5e3..7aad1b5df34056939d45f7c47b9f15017828f22c 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: misc.c,v 1.158 2021/01/11 02:12:57 dtucker Exp $ */
+/* $OpenBSD: misc.c,v 1.159 2021/01/15 02:32:41 dtucker Exp $ */
 /*
  * Copyright (c) 2000 Markus Friedl.  All rights reserved.
  * Copyright (c) 2005-2020 Damien Miller.  All rights reserved.
@@ -297,10 +297,10 @@ waitfd(int fd, int *timeoutp, short events)
        struct timeval t_start;
        int oerrno, r;
 
-       monotime_tv(&t_start);
        pfd.fd = fd;
        pfd.events = events;
        for (; *timeoutp >= 0;) {
+               monotime_tv(&t_start);
                r = poll(&pfd, 1, *timeoutp);
                oerrno = errno;
                ms_subtract_diff(&t_start, timeoutp);