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

fix RequestCtx is canceled (#1879) #1890

Merged
merged 1 commit into from
Oct 27, 2024

Conversation

ksw2000
Copy link
Contributor

@ksw2000 ksw2000 commented Oct 26, 2024

In my opinion, the root cause of issue #1879 is that the done channel in ctx.s is nil. We can simply create done channel in fakeServer during the initialization of RequestCtx.

Original

requestCtx.Init()
→ ctx.Init2
→ ctx.s = fakeServer        (the ctx.s.done is nil)

requestCtx.Err()
→ ctx.Done()        (generate the new buffered channel and send struct{}{} since the ctx.s.done is nil)
→ error is returned

Fix

requestCtx.Init()
→ ctx.Init2
→ ctx.s = fakeServer        (the ctx.s.done is initialized)

requestCtx.Err()
→ ctx.Done()        (return ctx.s.done since it is non nil)
→ error is nil

Create done channel in fakeServer during the initialization of newRequestCtx to prevent the done channel from being nil
@ksw2000 ksw2000 marked this pull request as ready for review October 26, 2024 11:20
@erikdubbelboer erikdubbelboer merged commit 803c25e into valyala:master Oct 27, 2024
15 checks passed
@erikdubbelboer
Copy link
Collaborator

Thanks, I like it!

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.

2 participants