From b2a5ba1890b8f3d5e8e1a52f223ca2fc43ea0afa Mon Sep 17 00:00:00 2001 From: deuce <> Date: Thu, 15 Mar 2018 07:58:17 +0000 Subject: [PATCH] More hacks to work around a known bug in Cryptlib SSH... "Sometimes" the write timeout value is used for read timeouts. Since we use a read timeout of zero, and a mutex, this can cause some serious delays in SSH processing. As a workaround, we set the write timeout to zero. However, a flush failure has historically been fatal. So, we now change the write timeout to one second just before a flush, and have a flush timeout not be fatal anymore... we set it back to zero after the flush. The fiddling with the write timouts will be removed once the bug is fixed, but the flush timout not being fatal may stay forever... add some comments to remind us to remove the hack in the future. --- src/sbbs3/main.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/sbbs3/main.cpp b/src/sbbs3/main.cpp index 5296226b18..455fdfea5e 100644 --- a/src/sbbs3/main.cpp +++ b/src/sbbs3/main.cpp @@ -2415,12 +2415,20 @@ void output_thread(void* arg) i=buftop-bufbot; // Pretend we sent it all } else { + // READ = WRITE TIMEOUT HACK... REMOVE WHEN FIXED + if(cryptStatusError(i=cryptSetAttribute(sbbs->ssh_session, CRYPT_OPTION_NET_WRITETIMEOUT, 1))) + GCESS(i, sbbs->client_socket, sbbs->ssh_session, "setting write timeout"); if(cryptStatusError((err=cryptFlushData(sbbs->ssh_session)))) { GCES(err, sbbs->cfg.node_num, sbbs->ssh_session, "flushing data"); ssh_errors++; - sbbs->online=FALSE; - i=buftop-bufbot; // Pretend we sent it all + if (err != CRYPT_ERROR_TIMEOUT) { + sbbs->online=FALSE; + i=buftop-bufbot; // Pretend we sent it all + } } + // READ = WRITE TIMEOUT HACK... REMOVE WHEN FIXED + if(cryptStatusError(i=cryptSetAttribute(sbbs->ssh_session, CRYPT_OPTION_NET_WRITETIMEOUT, 0))) + GCESS(i, sbbs->client_socket, sbbs->ssh_session, "setting write timeout"); } } pthread_mutex_unlock(&sbbs->ssh_mutex); @@ -5473,6 +5481,7 @@ NO_SSH: } if(cryptStatusError(i=cryptSetAttribute(sbbs->ssh_session, CRYPT_OPTION_NET_READTIMEOUT, 0))) GCESS(i, sbbs->client_socket, sbbs->ssh_session, "setting read timeout"); + // READ = WRITE TIMEOUT HACK... REMOVE WHEN FIXED if(cryptStatusError(i=cryptSetAttribute(sbbs->ssh_session, CRYPT_OPTION_NET_WRITETIMEOUT, 0))) GCESS(i, sbbs->client_socket, sbbs->ssh_session, "setting write timeout"); #if 0 -- GitLab