fn handle_session_event(&mut self, event: &Event) {
        let token = event.token();

        // handle error events first
        if event.is_error() {
            SERVER_EVENT_ERROR.increment();
            self.handle_error(token);
        }

        // handle write events before read events to reduce write
        // buffer growth if there is also a readable event
        if event.is_writable() {
            SERVER_EVENT_WRITE.increment();
            self.do_write(token);
        }

        // read events are handled last
        if event.is_readable() {
            SERVER_EVENT_READ.increment();
            let _ = self.do_read(token);
        }

        if let Ok(session) = self.poll.get_mut_session(token) {
            if session.do_handshake().is_ok() {
                trace!("handshake complete for session: {:?}", session);
                if let Ok(session) = self.poll.remove_session(token) {
                    if self.session_queue.try_send_any(session).is_err() {
                        error!("error sending session to worker");
                        TCP_ACCEPT_EX.increment();
                    }
                } else {
                    error!("error removing session from poller");
                    TCP_ACCEPT_EX.increment();
                }
            } else {
                trace!("handshake incomplete for session: {:?}", session);
            }
        }
    }
/// Handle an event on an existing session
Handle an event on an existing session
Handle an event on an existing session
fn handle_session_event(&mut self, event: &Event) {
        let token = event.token();
        // handle error events first
        if event.is_error() {
            SERVER_EVENT_ERROR.increment();
            self.handle_error(token);
        }
        // handle write events before read events to reduce write
        // buffer growth if there is also a readable event
        if event.is_writable() {
            SERVER_EVENT_WRITE.increment();
            self.do_write(token);
        }
        // read events are handled last
        if event.is_readable() {
            SERVER_EVENT_READ.increment();
            let _ = self.do_read(token);
        }
        if let Ok(session) = self.poll.get_mut_session(token) {
            if session.do_handshake().is_ok() {
                trace!("handshake complete for session: {:?}", session);
                if let Ok(session) = self.poll.remove_session(token) {
                    if self.session_queue.try_send_any(session).is_err() {
                        error!("error sending session to worker");
                        TCP_ACCEPT_EX.increment();
                    }
                } else {
                    error!("error removing session from poller");
                    TCP_ACCEPT_EX.increment();
                }
            } else {
                trace!("handshake incomplete for session: {:?}", session);
            }
        }
    }
fn handle_session_event ( & mut self , event : & Event ) { let token = event . token ( ) ; // handle error events first if event . is_error ( ) { SERVER_EVENT_ERROR . increment ( ) ; self . handle_error ( token ) ; } // handle write events before read events to reduce write // buffer growth if there is also a readable event if event . is_writable ( ) { SERVER_EVENT_WRITE . increment ( ) ; self . do_write ( token ) ; } // read events are handled last if event . is_readable ( ) { SERVER_EVENT_READ . increment ( ) ; let _ = self . do_read ( token ) ; } if let Ok ( session ) = self . poll . get_mut_session ( token ) { if session . do_handshake ( ) . is_ok ( ) { trace ! ( " " session ) ; if let Ok ( session ) = self . poll . remove_session ( token ) { if self . session_queue . try_send_any ( session ) . is_err ( ) { error ! ( " " ) ; TCP_ACCEPT_EX . increment ( ) ; } } else { error ! ( " " ) ; TCP_ACCEPT_EX . increment ( ) ; } } else { trace ! ( " " session ) ; } } }
Handle an event on an existing session
Handle an event on an existing session
&mut self
event
&Event
&mut self
event
&Event