fn handle_connection()

in src/flowgger/output/tls_output.rs [79:122]


    fn handle_connection(&self, connect_chosen: &str) -> io::Result<()> {
        let client = new_tcp(connect_chosen)?;
        let hostname = connect_chosen
            .split(':')
            .next()
            .unwrap_or_else(|| panic!("Invalid connection string: {}", connect_chosen));
        let _ = writeln!(stderr(), "Connected to {}", connect_chosen);
        let sslclient = match self.tls_config.connector.connect(hostname, client) {
            Err(_) => {
                return Err(io::Error::new(
                    io::ErrorKind::ConnectionAborted,
                    "SSL handshake aborted by the server",
                ))
            }
            Ok(sslclient) => sslclient,
        };
        let _ = writeln!(stderr(), "Completed SSL handshake with {}", connect_chosen);
        let mut writer = BufWriter::new(sslclient);
        let merger = &self.merger;
        loop {
            let mut bytes = match { self.arx.lock().unwrap().recv() } {
                Ok(line) => line,
                Err(_) => {
                    return Err(io::Error::new(
                        io::ErrorKind::Other,
                        "Cannot read the message queue any more",
                    ))
                }
            };
            if let Some(ref merger) = *merger {
                merger.frame(&mut bytes);
            }
            match writer.write_all(&bytes) {
                Ok(_) => {}
                Err(e) => match e.kind() {
                    ErrorKind::Interrupted => continue,
                    _ => return Err(e),
                },
            };
            if !self.tls_config.async_ {
                writer.flush()?;
            }
        }
    }