From 1c042cdc6c8e4669c1d204b7ec20ff35139c3b07 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Mon, 18 Mar 2019 11:57:37 +0100 Subject: [PATCH] proxy: listener error handling fixup If the listening socket goes into some error state we'll get std::io::Errors rather than higher level errors from the native_tls::TlsAcceptor, those are usually fatal. (Ran into this after performing a shutdown() on the file descriptor, after which the future just endlessly loops in accept().) Signed-off-by: Wolfgang Bumiller --- src/bin/proxmox-backup-proxy.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/bin/proxmox-backup-proxy.rs b/src/bin/proxmox-backup-proxy.rs index 03e71563..e12758c7 100644 --- a/src/bin/proxmox-backup-proxy.rs +++ b/src/bin/proxmox-backup-proxy.rs @@ -76,7 +76,15 @@ fn run() -> Result<(), Error> { // the cert and closes the connection, so we follow up with mapping // it to an option and then filtering None with filter_map Ok(c) => Ok::<_, Error>(Some(c)), - Err(_) => Ok(None), + Err(e) => { + if let Some(_io) = e.downcast_ref::() { + // "real" IO errors should not simply be ignored + bail!("shutting down..."); + } else { + // handshake errors just get filtered by filter_map() below: + Ok(None) + } + } }) .filter_map(|r| { // Filter out the Nones