=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ssh/misc.c,v retrieving revision 1.186 retrieving revision 1.187 diff -u -r1.186 -r1.187 --- src/usr.bin/ssh/misc.c 2023/08/18 01:37:41 1.186 +++ src/usr.bin/ssh/misc.c 2023/08/28 03:31:16 1.187 @@ -1,4 +1,4 @@ -/* $OpenBSD: misc.c,v 1.186 2023/08/18 01:37:41 djm Exp $ */ +/* $OpenBSD: misc.c,v 1.187 2023/08/28 03:31:16 djm Exp $ */ /* * Copyright (c) 2000 Markus Friedl. All rights reserved. * Copyright (c) 2005-2020 Damien Miller. All rights reserved. @@ -2792,22 +2792,33 @@ ptimeout_deadline_tsp(pt, &p); } -/* Specify a poll/ppoll deadline at wall clock monotime 'when' */ +/* Specify a poll/ppoll deadline at wall clock monotime 'when' (timespec) */ void -ptimeout_deadline_monotime(struct timespec *pt, time_t when) +ptimeout_deadline_monotime_tsp(struct timespec *pt, struct timespec *when) { struct timespec now, t; - t.tv_sec = when; - t.tv_nsec = 0; monotime_ts(&now); - if (timespeccmp(&now, &t, >=)) - ptimeout_deadline_sec(pt, 0); - else { - timespecsub(&t, &now, &t); + if (timespeccmp(&now, when, >=)) { + /* 'when' is now or in the past. Timeout ASAP */ + pt->tv_sec = 0; + pt->tv_nsec = 0; + } else { + timespecsub(when, &now, &t); ptimeout_deadline_tsp(pt, &t); } +} + +/* Specify a poll/ppoll deadline at wall clock monotime 'when' */ +void +ptimeout_deadline_monotime(struct timespec *pt, time_t when) +{ + struct timespec t; + + t.tv_sec = when; + t.tv_nsec = 0; + ptimeout_deadline_monotime_tsp(pt, &t); } /* Get a poll(2) timeout value in milliseconds */