Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flush qlog streamer before closing the connection #1629

Merged
merged 2 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions qlog/src/streamer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,12 @@ impl QlogStreamer {
}
}

impl Drop for QlogStreamer {
fn drop(&mut self) {
let _ = self.finish_log();
}
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
46 changes: 17 additions & 29 deletions quiche/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1625,21 +1625,6 @@ macro_rules! push_frame_to_pkt {
}};
}

/// Conditional qlog actions.
///
/// Executes the provided body if the qlog feature is enabled and quiche
/// has been configured with a log writer.
macro_rules! qlog_with {
($qlog:expr, $qlog_streamer_ref:ident, $body:block) => {{
#[cfg(feature = "qlog")]
{
if let Some($qlog_streamer_ref) = &mut $qlog.streamer {
$body
}
}
}};
}

/// Executes the provided body if the qlog feature is enabled, quiche has been
/// configured with a log writer, the event's importance is within the
/// configured level.
Expand Down Expand Up @@ -2155,7 +2140,7 @@ impl Connection {
if self.is_stateless_reset(&buf[len - left..len]) {
trace!("{} packet is a stateless reset", self.trace_id);

self.closed = true;
self.mark_closed();
}

left
Expand Down Expand Up @@ -5555,11 +5540,7 @@ impl Connection {
if draining_timer <= now {
trace!("{} draining timeout expired", self.trace_id);

qlog_with!(self.qlog, q, {
q.finish_log().ok();
});

self.closed = true;
self.mark_closed();
}

// Draining timer takes precedence over all other timers. If it is
Expand All @@ -5572,11 +5553,7 @@ impl Connection {
if timer <= now {
trace!("{} idle timeout expired", self.trace_id);

qlog_with!(self.qlog, q, {
q.finish_log().ok();
});

self.closed = true;
self.mark_closed();
self.timed_out = true;
return;
}
Expand Down Expand Up @@ -5630,11 +5607,13 @@ impl Connection {
Some(pid) =>
if self.set_active_path(pid, now).is_err() {
// The connection cannot continue.
self.closed = true;
self.mark_closed();
},

// The connection cannot continue.
None => self.closed = true,
None => {
self.mark_closed();
},
}
}
}
Expand Down Expand Up @@ -6059,7 +6038,7 @@ impl Connection {

// When no packet was successfully processed close connection immediately.
if self.recv_count == 0 {
self.closed = true;
self.mark_closed();
}

Ok(())
Expand Down Expand Up @@ -7436,6 +7415,15 @@ impl Connection {

Ok(pid)
}

// Marks the connection as closed and does any related tidyup.
fn mark_closed(&mut self) {
#[cfg(feature = "qlog")]
{
self.qlog.streamer = None;
}
self.closed = true;
}
}

#[cfg(feature = "boringssl-boring-crate")]
Expand Down
Loading