remove unused expired value from Handshake (#9732)

This commit is contained in:
Marek Kotewicz 2018-10-10 23:17:17 +02:00 committed by GitHub
parent fa2f99641f
commit 581cd97ba1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 37 deletions

View File

@ -69,8 +69,6 @@ pub struct Handshake {
pub auth_cipher: Bytes,
/// A copy of received encrypted ack packet
pub ack_cipher: Bytes,
/// This Handshake is marked for deletion flag
pub expired: bool,
}
const V4_AUTH_PACKET_SIZE: usize = 307;
@ -95,15 +93,9 @@ impl Handshake {
remote_version: PROTOCOL_VERSION,
auth_cipher: Bytes::new(),
ack_cipher: Bytes::new(),
expired: false,
})
}
/// Check if this handshake is expired.
pub fn expired(&self) -> bool {
self.expired
}
/// Start a handshake
pub fn start<Message>(&mut self, io: &IoContext<Message>, host: &HostInfo, originated: bool) -> Result<(), Error> where Message: Send + Clone+ Sync + 'static {
self.originated = originated;
@ -125,28 +117,26 @@ impl Handshake {
/// Readable IO handler. Drives the state change.
pub fn readable<Message>(&mut self, io: &IoContext<Message>, host: &HostInfo) -> Result<(), Error> where Message: Send + Clone + Sync + 'static {
if !self.expired() {
while let Some(data) = self.connection.readable()? {
match self.state {
HandshakeState::New => {},
HandshakeState::StartSession => {},
HandshakeState::ReadingAuth => {
self.read_auth(io, host.secret(), &data)?;
},
HandshakeState::ReadingAuthEip8 => {
self.read_auth_eip8(io, host.secret(), &data)?;
},
HandshakeState::ReadingAck => {
self.read_ack(host.secret(), &data)?;
},
HandshakeState::ReadingAckEip8 => {
self.read_ack_eip8(host.secret(), &data)?;
},
}
if self.state == HandshakeState::StartSession {
io.clear_timer(self.connection.token).ok();
break;
}
while let Some(data) = self.connection.readable()? {
match self.state {
HandshakeState::New => {},
HandshakeState::StartSession => {},
HandshakeState::ReadingAuth => {
self.read_auth(io, host.secret(), &data)?;
},
HandshakeState::ReadingAuthEip8 => {
self.read_auth_eip8(io, host.secret(), &data)?;
},
HandshakeState::ReadingAck => {
self.read_ack(host.secret(), &data)?;
},
HandshakeState::ReadingAckEip8 => {
self.read_ack_eip8(host.secret(), &data)?;
},
}
if self.state == HandshakeState::StartSession {
io.clear_timer(self.connection.token).ok();
break;
}
}
Ok(())
@ -154,9 +144,7 @@ impl Handshake {
/// Writable IO handler.
pub fn writable<Message>(&mut self, io: &IoContext<Message>) -> Result<(), Error> where Message: Send + Clone + Sync + 'static {
if !self.expired() {
self.connection.writable(io)?;
}
self.connection.writable(io)?;
Ok(())
}

View File

@ -166,10 +166,7 @@ impl Session {
/// Check if this session is expired.
pub fn expired(&self) -> bool {
match self.state {
State::Handshake(ref h) => self.expired || h.expired(),
_ => self.expired,
}
self.expired
}
/// Check if this session is over and there is nothing to be sent.