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

martian: improve error logging in response writing #631

Merged
merged 5 commits into from
Jan 5, 2024

Conversation

mmatczuk
Copy link
Contributor

@mmatczuk mmatczuk commented Jan 3, 2024

This patch extracts response writing to separate method and uses isClosedConnError() for smarter error logging like we do in case if readRequest().

CloseAfrerReply is removed for easier refactoring and later function reuse.

CloseAfterReply was needed to support KGP in SauceConnect 4.9.
It's not needed now.
@mmatczuk mmatczuk changed the title WIP moderize martian martian: improve error logging in response writing Jan 3, 2024
…n connect

In 4b403a3 we added detection of client disconnects.
This extends it with later added isClosedConnError() that enables it on Windows.
req := res.Request

if p.WriteTimeout > 0 {
if deadlineErr := conn.SetWriteDeadline(time.Now().Add(p.WriteTimeout)); deadlineErr != nil {
log.Errorf(req.Context(), "can't set write deadline: %v", deadlineErr)
}
defer conn.SetWriteDeadline(time.Time{})
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice catch!

Copy link
Contributor

Choose a reason for hiding this comment

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

We should also reset the timer while reading.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For reading it's ok due to tricky code.

@Choraden
Copy link
Contributor

Choraden commented Jan 4, 2024

LGTM.

It looks like the last commit's message references wrong commit.

@mmatczuk mmatczuk merged commit 21a33c5 into main Jan 5, 2024
4 checks passed
@mmatczuk mmatczuk deleted the mmt/moderize_martian_v2 branch January 5, 2024 14:14
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.

None yet

2 participants