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 cancel via context and respect context deadline #14

Merged
merged 2 commits into from
Mar 16, 2018

Conversation

moogle19
Copy link

see #11

linux/hci/gap.go Outdated
@@ -206,31 +206,39 @@ func (h *HCI) Dial(ctx context.Context, a ble.Addr) (ble.Client, error) {
return nil, err
}
var tmo <-chan time.Time
if h.dialerTmo != time.Duration(0) {
if deadline, ok := ctx.Deadline(); ok {
tmo = time.After(time.Until(deadline))
Copy link

@estutzenberger estutzenberger Mar 14, 2018

Choose a reason for hiding this comment

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

I'm not sure if this is necessary. If the context has a deadline, then it is already effectively a timeout. If the goal is to override the dialer timeout, then I think the select on <-ctx.Done() could be removed since selecting <-tmo is the same thing. Otherwise, I think the changes look great.

Copy link

@estutzenberger estutzenberger left a comment

Choose a reason for hiding this comment

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

Looks great! Thanks for working on it.

@moogle19 moogle19 merged commit 1dd6d60 into go-ble:master Mar 16, 2018
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