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

*: Use http.Request.WithContext instead of Cancel #7269

Merged
merged 1 commit into from
Feb 2, 2017
Merged

*: Use http.Request.WithContext instead of Cancel #7269

merged 1 commit into from
Feb 2, 2017

Conversation

sinsharat
Copy link
Contributor

@xiang90
Copy link
Contributor

xiang90 commented Feb 2, 2017

CI failure is not related: see #6934

@@ -239,7 +239,6 @@ func TimeToLiveHTTP(ctx context.Context, id lease.LeaseID, keys bool, url string
return nil, derr
}
case <-ctx.Done():
Copy link
Contributor

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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()
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 still keep this cancel. the go routine exit at line 117 will not trigger the defer func at line 114.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

@xiang90
Copy link
Contributor

xiang90 commented Feb 2, 2017

LGTM. defer to @heyitsanthony

@heyitsanthony
Copy link
Contributor

lgtm

@xiang90 xiang90 merged commit 56c706f into etcd-io:master Feb 2, 2017
@sinsharat sinsharat deleted the use_requestWithContext_for_cancel branch February 2, 2017 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants