Skip to content
This repository has been archived by the owner on Feb 24, 2021. It is now read-only.

Commit

Permalink
fix: wait for handshake to complete before returning
Browse files Browse the repository at this point in the history
That makes sure we aren't still writing/reading after we relinquish control.

fixes #40

may be related to ipfs/kubo#6197?
  • Loading branch information
Stebalien committed Jun 15, 2019
1 parent 2078160 commit d81b453
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,12 @@ func (s *secureSession) runHandshake(ctx context.Context) error {
var err error
select {
case <-ctx.Done():
err = ctx.Err()

// State unknown. We *have* to close this.
s.insecure.Close()
err = ctx.Err()
// Wait for the handshake to return.
<-result
case err = <-result:
}
return err
Expand Down

0 comments on commit d81b453

Please sign in to comment.