diff dbutil.c @ 1835:90ac15aeac43

Bring back recently removed channel->flushing This resolves the "sleep 10&echo hello" case which should return immediately
author Matt Johnston <matt@codeconstruct.com.au>
date Thu, 14 Oct 2021 20:55:15 +0800
parents 870f6e386a0b
children 7f549ee3df48
line wrap: on
line diff
--- a/dbutil.c	Tue Oct 12 23:32:10 2021 +0800
+++ b/dbutil.c	Thu Oct 14 20:55:15 2021 +0800
@@ -715,3 +715,22 @@
 	m_free(fn_dir);
 #endif
 }
+
+int fd_read_pending(int fd) {
+	fd_set fds;
+	struct timeval timeout;
+
+	DROPBEAR_FD_ZERO(&fds);
+	FD_SET(fd, &fds);
+	while (1) {
+		timeout.tv_sec = 0;
+		timeout.tv_usec = 0;
+		if (select(fd+1, &fds, NULL, NULL, &timeout) < 0) {
+			if (errno == EINTR) {
+				continue;
+			}
+			return 0;
+		}
+		return FD_ISSET(fd, &fds);
+	}
+}