summaryrefslogtreecommitdiff
path: root/channels.c
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2023-01-06 02:38:23 +0000
committerDamien Miller <djm@mindrot.org>2023-01-06 16:21:39 +1100
commitd478cdc7ad6edd4b1bcd1e86fb2f23194ff33d5a (patch)
treed0af0c8e4bedf3c76a24d02e2508bc7dea48c0bc /channels.c
parent4adf3817a24efe99b06e62630577d683c7cd8065 (diff)
downloadopenssh-git-d478cdc7ad6edd4b1bcd1e86fb2f23194ff33d5a.tar.gz
upstream: replace manual poll/ppoll timeout math with ptimeout API
feedback markus / ok markus dtucker OpenBSD-Commit-ID: c5ec4f2d52684cdb788cd9cbc1bcf89464014be2
Diffstat (limited to 'channels.c')
-rw-r--r--channels.c27
1 files changed, 9 insertions, 18 deletions
diff --git a/channels.c b/channels.c
index 7c2c882d..5541e904 100644
--- a/channels.c
+++ b/channels.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: channels.c,v 1.421 2022/11/18 19:47:40 mbuhl Exp $ */
+/* $OpenBSD: channels.c,v 1.422 2023/01/06 02:38:23 djm Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -2410,7 +2410,7 @@ channel_garbage_collect(struct ssh *ssh, Channel *c)
enum channel_table { CHAN_PRE, CHAN_POST };
static void
-channel_handler(struct ssh *ssh, int table, time_t *unpause_secs)
+channel_handler(struct ssh *ssh, int table, struct timespec *timeout)
{
struct ssh_channels *sc = ssh->chanctxt;
chan_fn **ftab = table == CHAN_PRE ? sc->channel_pre : sc->channel_post;
@@ -2419,8 +2419,6 @@ channel_handler(struct ssh *ssh, int table, time_t *unpause_secs)
time_t now;
now = monotime();
- if (unpause_secs != NULL)
- *unpause_secs = 0;
for (i = 0, oalloc = sc->channels_alloc; i < oalloc; i++) {
c = sc->channels[i];
if (c == NULL)
@@ -2440,24 +2438,17 @@ channel_handler(struct ssh *ssh, int table, time_t *unpause_secs)
*/
if (c->notbefore <= now)
(*ftab[c->type])(ssh, c);
- else if (unpause_secs != NULL) {
+ else if (timeout != NULL) {
/*
- * Collect the time that the earliest
- * channel comes off pause.
+ * Arrange for poll wakeup when channel pause
+ * timer expires.
*/
- debug3_f("chan %d: skip for %d more "
- "seconds", c->self,
- (int)(c->notbefore - now));
- if (*unpause_secs == 0 ||
- (c->notbefore - now) < *unpause_secs)
- *unpause_secs = c->notbefore - now;
+ ptimeout_deadline_monotime(timeout,
+ c->notbefore);
}
}
channel_garbage_collect(ssh, c);
}
- if (unpause_secs != NULL && *unpause_secs != 0)
- debug3_f("first channel unpauses in %d seconds",
- (int)*unpause_secs);
}
/*
@@ -2603,7 +2594,7 @@ channel_prepare_pollfd(Channel *c, u_int *next_pollfd,
/* * Allocate/prepare poll structure */
void
channel_prepare_poll(struct ssh *ssh, struct pollfd **pfdp, u_int *npfd_allocp,
- u_int *npfd_activep, u_int npfd_reserved, time_t *minwait_secs)
+ u_int *npfd_activep, u_int npfd_reserved, struct timespec *timeout)
{
struct ssh_channels *sc = ssh->chanctxt;
u_int i, oalloc, p, npfd = npfd_reserved;
@@ -2627,7 +2618,7 @@ channel_prepare_poll(struct ssh *ssh, struct pollfd **pfdp, u_int *npfd_allocp,
*npfd_activep = npfd_reserved;
oalloc = sc->channels_alloc;
- channel_handler(ssh, CHAN_PRE, minwait_secs);
+ channel_handler(ssh, CHAN_PRE, timeout);
if (oalloc != sc->channels_alloc) {
/* shouldn't happen */