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 <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2019-03-18 11:57:37 +01:00
parent 60864b1b56
commit 1c042cdc6c
1 changed files with 9 additions and 1 deletions

View File

@ -76,7 +76,15 @@ fn run() -> Result<(), Error> {
// the cert and closes the connection, so we follow up with mapping // the cert and closes the connection, so we follow up with mapping
// it to an option and then filtering None with filter_map // it to an option and then filtering None with filter_map
Ok(c) => Ok::<_, Error>(Some(c)), Ok(c) => Ok::<_, Error>(Some(c)),
Err(_) => Ok(None), Err(e) => {
if let Some(_io) = e.downcast_ref::<std::io::Error>() {
// "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_map(|r| {
// Filter out the Nones // Filter out the Nones