Skip to content

Commit

Permalink
fix(timeout): implements cancel on drop
Browse files Browse the repository at this point in the history
Co-Authored-By: Eloi DEMOLIS <eloi.demolis@clever-cloud.com>
Signed-off-by: Florentin Dubois <florentin.dubois@clever-cloud.com>
  • Loading branch information
FlorentinDUBOIS and Wonshtrum committed Oct 23, 2023
1 parent 22749c6 commit 89bf73a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/src/https.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ impl HttpsSession {

fn upgrade_expect(
&mut self,
expect: ExpectProxyProtocol<MioTcpStream>,
mut expect: ExpectProxyProtocol<MioTcpStream>,
ssl: ServerConnection,
) -> Option<HttpsStateMachine> {
if let Some(ref addresses) = expect.addresses {
Expand Down Expand Up @@ -245,7 +245,10 @@ impl HttpsSession {
}

// currently, only happens in expect proxy protocol with AF_UNSPEC address
// error!("failed to upgrade from expect");
if !expect.container_frontend_timeout.cancel() {
error!("failed to cancel request timeout on expect upgrade phase for 'expect proxy protocol with AF_UNSPEC address'");
}

None
}

Expand Down
8 changes: 8 additions & 0 deletions lib/src/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,14 @@ impl TimeoutContainer {
}
}

impl std::ops::Drop for TimeoutContainer {
fn drop(&mut self) {
if self.cancel() {
error!("Cancel a dangling timeout that haven't be handled in session lifecycle, token ({:?}), duration {}", self.token, self.duration);
}
}
}

#[derive(Copy, Clone, Debug)]
struct WheelEntry {
next_tick: Tick,
Expand Down

0 comments on commit 89bf73a

Please sign in to comment.