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

Conversation

FranzBusch
Copy link
Contributor

Motivation

I was debugging some connection problems and enabled qlog; however, often I did not get output. My use-case is going through the FFI layer which instantiates a BufferedWriter for the file. After looking through the code a bit it appears that the QLogStreamer is not flushed on all close paths which can lead to missing logs.

Modification

Make sure that on every close path the streamer is flushed and closed as well.

@FranzBusch FranzBusch requested a review from a team as a code owner October 10, 2023 15:58
@ghedo
Copy link
Member

ghedo commented Oct 12, 2023

This looks good, but I think it might even better to implement the Drop trait for QlogStreamer and flush inside that instead, so we automatically catch all cases where flushing is needed, @LPardue thoughts?

@LPardue
Copy link
Contributor

LPardue commented Oct 13, 2023

Yeah Drop sounds good.

@FranzBusch FranzBusch force-pushed the fb-qlog-flush branch 2 times, most recently from 7fd6762 to 08874a9 Compare November 14, 2023 10:45
@FranzBusch
Copy link
Contributor Author

@ghedo @LPardue I have updated the code to implement Drop for the QLogStreamer but I also manually set the streamer to None in some paths so that we flush as soon as possible. That's often really helpful when debugging something with QLog. The Drop implementation makes sure that we are going to flush in all the remaining cases.

Copy link
Contributor

@LPardue LPardue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few nits but looking good. Also please rebase.

quiche/src/lib.rs Outdated Show resolved Hide resolved
quiche/src/lib.rs Outdated Show resolved Hide resolved
@FranzBusch FranzBusch requested a review from LPardue December 4, 2023 13:41
@FranzBusch FranzBusch force-pushed the fb-qlog-flush branch 3 times, most recently from bb2b33e to 20884eb Compare December 4, 2023 13:53
Comment on lines 7436 to 7438
qlog_with!(self.qlog, _q, {
self.qlog.streamer = None;
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
qlog_with!(self.qlog, _q, {
self.qlog.streamer = None;
});
qlog_with!(self.qlog, q, {
q = None;
});

this should work

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Not writing Rust usually 😉

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok sorry that didn't work, my bad. Let me try something else

# Motivation
I was debugging some connection problems and enabled qlog; however, often I did not get output. My use-case is going through the FFI layer which instantiates a `BufferedWriter` for the file.
After looking through the code a bit it appears that the `QLogStreamer` is not flushed on all close paths which can lead to missing logs.

# Modification
Make sure that on every close path the streamer is flushed and closed as well.
Copy link
Contributor

@LPardue LPardue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM now, thanks.

We'll probably hold on merging just this moment in order to batch up some other qlog-reated changes.

@LPardue LPardue merged commit 4269906 into cloudflare:master Dec 13, 2023
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants