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

Cancellation #44

Merged
merged 11 commits into from
Jan 10, 2022
1 change: 0 additions & 1 deletion wormhole/recv.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ func (c *Client) Receive(ctx context.Context, code string, disableListener bool,
answer := &genericMessage{
Error: &errStr,
}
ctx := context.Background()

err = clientProto.WriteAppData(ctx, answer)
if err != nil {
Expand Down
8 changes: 3 additions & 5 deletions wormhole/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,12 +386,11 @@ func (c *Client) sendFileDirectory(ctx context.Context, offer *offerMsg, r io.Re
totalSize = offer.Directory.ZipSize
}

var cancel func()
ctx, cancel = context.WithCancel(ctx)
defer cancel()

go func() {
<-ctx.Done()
ch <- SendResult{
Error: errors.New("context canceled"),
}
conn.Close()
}()

Expand Down Expand Up @@ -444,7 +443,6 @@ func (c *Client) sendFileDirectory(ctx context.Context, offer *offerMsg, r io.Re
ch <- SendResult{
OK: true,
}
close(ch)
}()

return pwStr, ch, nil
Expand Down