From 411520fd7ff489462f0138f559337d42cd4f643d Mon Sep 17 00:00:00 2001
From: deuce <>
Date: Thu, 5 Mar 2020 02:21:19 +0000
Subject: [PATCH] Increase putcom() timeout to 10 seconds to allow network
 buffers to drain.

---
 src/syncterm/telnet_io.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/syncterm/telnet_io.c b/src/syncterm/telnet_io.c
index 5f559120ea..1baab42b6c 100644
--- a/src/syncterm/telnet_io.c
+++ b/src/syncterm/telnet_io.c
@@ -51,8 +51,19 @@ void putcom(char* buf, size_t len)
 	FD_ZERO(&wds);
 	FD_SET(telnet_sock, &wds);
 	struct timeval tv;
-	tv.tv_sec=0;
-	tv.tv_usec=1000;
+	tv.tv_sec=10;
+	tv.tv_usec=0;
+	/*
+	 * Note, this select() call was added when debugging file transfer
+	 * issues presumably because something made it appear to "hang forever".
+	 * Since blocking sockets are used, this is very much not a complete
+	 * fix as the buffer size will usually be greater than the one byte
+	 * select() guarantees you will be able to send().
+	 *
+	 * The original fix waited 1ms in select(), which is unlikely to actually
+	 * allow the ACK to come back fast enough to clear a full output buffer.
+	 * I've increased it to 10s and left the select() in place.
+	 */
 	if(select(telnet_sock+1, NULL, &wds, NULL, &tv) == 1) {
 		char	str[128];
 		char*	p=str;
-- 
GitLab