fn fail_with<E>(&mut self, e: E)
    where
        E: Into<SharedPeerError>,
    {
        let e = e.into();
        debug!(%e,
               connection_state = ?self.state,
               client_receiver = ?self.client_rx,
               "failing peer service with error");
        // Update the shared error slot
        let mut guard = self
            .error_slot
            .0
            .lock()
            .expect("mutex should be unpoisoned");
        if let Some(original_error) = guard.clone() {
            // This panic typically happens due to these bugs:
            // * we mark a connection as failed without using fail_with
            // * we call fail_with without checking for a failed connection
            //   state
            //
            // See the original bug #1510 and PR #1531, and the later bug #1599
            // and PR #1600.
            panic!(
                "calling fail_with on already-failed connection state: failed connections must stop processing pending requests and responses, then close the connection. state: {:?} original error: {:?} new error: {:?} client receiver: {:?}",
                self.state,
                original_error,
                e,
                self.client_rx
            );
        } else {
            *guard = Some(e);
        }
        // Drop the guard immediately to release the mutex.
        std::mem::drop(guard);

        // We want to close the client channel and set State::Failed so
        // that we can flush any pending client requests. However, we may have
        // an outstanding client request in State::AwaitingResponse, so
        // we need to deal with it first if it exists.
        self.client_rx.close();
        let old_state = std::mem::replace(&mut self.state, State::Failed);
        if let State::AwaitingResponse { tx, .. } = old_state {
            // We know the slot has Some(e) because we just set it above,
            // and the error slot is never unset.
            let e = self.error_slot.try_get_error().unwrap();
            let _ = tx.send(Err(e));
        }
    }
/// Marks the peer as having failed with error `e`.
Marks the peer as having failed with error `e`.
Marks the peer as having failed with error ` e ` .
fn fail_with<E>(&mut self, e: E)
    where
        E: Into<SharedPeerError>,
    {
        let e = e.into();
        debug!(%e,
               connection_state = ?self.state,
               client_receiver = ?self.client_rx,
               "failing peer service with error");
        // Update the shared error slot
        let mut guard = self
            .error_slot
            .0
            .lock()
            .expect("mutex should be unpoisoned");
        if let Some(original_error) = guard.clone() {
            // This panic typically happens due to these bugs:
            // * we mark a connection as failed without using fail_with
            // * we call fail_with without checking for a failed connection
            //   state
            //
            // See the original bug #1510 and PR #1531, and the later bug #1599
            // and PR #1600.
            panic!(
                "calling fail_with on already-failed connection state: failed connections must stop processing pending requests and responses, then close the connection. state: {:?} original error: {:?} new error: {:?} client receiver: {:?}",
                self.state,
                original_error,
                e,
                self.client_rx
            );
        } else {
            *guard = Some(e);
        }
        // Drop the guard immediately to release the mutex.
        std::mem::drop(guard);
        // We want to close the client channel and set State::Failed so
        // that we can flush any pending client requests. However, we may have
        // an outstanding client request in State::AwaitingResponse, so
        // we need to deal with it first if it exists.
        self.client_rx.close();
        let old_state = std::mem::replace(&mut self.state, State::Failed);
        if let State::AwaitingResponse { tx, .. } = old_state {
            // We know the slot has Some(e) because we just set it above,
            // and the error slot is never unset.
            let e = self.error_slot.try_get_error().unwrap();
            let _ = tx.send(Err(e));
        }
    }
fn fail_with < E > ( & mut self , e : E ) where E : Into < SharedPeerError > , { let e = e . into ( ) ; debug ! ( e connection_state self state client_receiver self client_rx " " ) ; // Update the shared error slot let mut guard = self . error_slot . 0 . lock ( ) . expect ( " " ) ; if let Some ( original_error ) = guard . clone ( ) { // This panic typically happens due to these bugs: // * we mark a connection as failed without using fail_with // * we call fail_with without checking for a failed connection //   state // // See the original bug #1510 and PR #1531, and the later bug #1599 // and PR #1600. panic ! ( " " self state original_error e self client_rx ) ; } else { * guard = Some ( e ) ; } // Drop the guard immediately to release the mutex. std :: mem :: drop ( guard ) ; // We want to close the client channel and set State::Failed so // that we can flush any pending client requests. However, we may have // an outstanding client request in State::AwaitingResponse, so // we need to deal with it first if it exists. self . client_rx . close ( ) ; let old_state = std :: mem :: replace ( & mut self . state , State :: Failed ) ; if let State :: AwaitingResponse { tx , .. } = old_state { // We know the slot has Some(e) because we just set it above, // and the error slot is never unset. let e = self . error_slot . try_get_error ( ) . unwrap ( ) ; let _ = tx . send ( Err ( e ) ) ; } }
Marks the peer as having failed with error `e`.
Marks the peer as having failed with error ` e ` .
&mut self
e
E