-
Notifications
You must be signed in to change notification settings - Fork 9.8k
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
*: Use http.Request.WithContext instead of Cancel #7269
*: Use http.Request.WithContext instead of Cancel #7269
Conversation
CI failure is not related: see #6934 |
lease/leasehttp/http.go
Outdated
@@ -239,7 +239,6 @@ func TimeToLiveHTTP(ctx context.Context, id lease.LeaseID, keys bool, url string | |||
return nil, derr | |||
} | |||
case <-ctx.Done(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to wait on this anymore? if ctx is cancelled, the cc.Do at line 212 will return, thus trigger line 237. Right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can remove the go routine at 211 with this change i think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What you are saying is right will change it.
if ok { | ||
closeCh := closeNotifier.CloseNotify() | ||
go func() { | ||
select { | ||
case <-closeCh: | ||
atomic.StoreInt32(&requestClosed, 1) | ||
plog.Printf("client %v closed request prematurely", clientreq.RemoteAddr) | ||
cancel() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should still keep this cancel. the go routine exit at line 117 will not trigger the defer func at line 114.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@xiang90 its not required there. It will still work fine. The reason being the code is written in such a way that on either of these select triggered, the method will exit and also cancel will get called. The defer func after the select causes it to end i think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i read the code again. what you said makes sense. Thanks.
LGTM. defer to @heyitsanthony |
lgtm |
#6953