summaryrefslogtreecommitdiff
path: root/usr.bin/ssh/misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/ssh/misc.c')
-rw-r--r--usr.bin/ssh/misc.c29
1 files changed, 20 insertions, 9 deletions
diff --git a/usr.bin/ssh/misc.c b/usr.bin/ssh/misc.c
index 52d79e748d9..59ee9c9edfc 100644
--- a/usr.bin/ssh/misc.c
+++ b/usr.bin/ssh/misc.c
@@ -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,24 +2792,35 @@ ptimeout_deadline_ms(struct timespec *pt, long ms)
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 */
int
ptimeout_get_ms(struct timespec *pt)