=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ssh/misc.c,v retrieving revision 1.142 retrieving revision 1.143 diff -u -r1.142 -r1.143 --- src/usr.bin/ssh/misc.c 2019/09/03 08:32:11 1.142 +++ src/usr.bin/ssh/misc.c 2019/11/22 06:50:30 1.143 @@ -1,4 +1,4 @@ -/* $OpenBSD: misc.c,v 1.142 2019/09/03 08:32:11 djm Exp $ */ +/* $OpenBSD: misc.c,v 1.143 2019/11/22 06:50:30 dtucker Exp $ */ /* * Copyright (c) 2000 Markus Friedl. All rights reserved. * Copyright (c) 2005,2006 Damien Miller. All rights reserved. @@ -211,12 +211,12 @@ } /* - * Wait up to *timeoutp milliseconds for fd to be readable. Updates + * Wait up to *timeoutp milliseconds for events on fd. Updates * *timeoutp with time remaining. * Returns 0 if fd ready or -1 on timeout or error (see errno). */ -int -waitrfd(int fd, int *timeoutp) +static int +waitfd(int fd, int *timeoutp, short events) { struct pollfd pfd; struct timeval t_start; @@ -224,7 +224,7 @@ monotime_tv(&t_start); pfd.fd = fd; - pfd.events = POLLIN; + pfd.events = events; for (; *timeoutp >= 0;) { r = poll(&pfd, 1, *timeoutp); oerrno = errno; @@ -243,6 +243,16 @@ } /* + * Wait up to *timeoutp milliseconds for fd to be readable. Updates + * *timeoutp with time remaining. + * Returns 0 if fd ready or -1 on timeout or error (see errno). + */ +int +waitrfd(int fd, int *timeoutp) { + return waitfd(fd, timeoutp, POLLIN); +} + +/* * Attempt a non-blocking connect(2) to the specified address, waiting up to * *timeoutp milliseconds for the connection to complete. If the timeout is * <=0, then wait indefinitely. @@ -268,7 +278,7 @@ } else if (errno != EINPROGRESS) return -1; - if (waitrfd(sockfd, timeoutp) == -1) + if (waitfd(sockfd, timeoutp, POLLIN | POLLOUT) == -1) return -1; /* Completed or failed */