Skip to content

Commit

Permalink
Fire cancel locally even if remote cancel fails (#120)
Browse files Browse the repository at this point in the history
* fix: if sending cancel message to remote peer fails, should still fire cancel on local FSM
  • Loading branch information
dirkmc authored Nov 30, 2020
1 parent ca8adef commit b9b87cb
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions impl/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,13 +263,22 @@ func (m *manager) CloseDataTransferChannel(ctx context.Context, chid datatransfe
log.Warnf("unable to close channel: %w", err)
}

if err := m.dataTransferNetwork.SendMessage(ctx, chst.OtherPeer(), m.cancelMessage(chid)); err != nil {
err = m.dataTransferNetwork.SendMessage(ctx, chst.OtherPeer(), m.cancelMessage(chid))
if err != nil {
err = fmt.Errorf("Unable to send cancel message: %w", err)
_ = m.OnRequestDisconnected(ctx, chid)
log.Warn(err)
}

fsmerr := m.channels.Cancel(chid)
if err != nil {
return err
}
if fsmerr != nil {
return xerrors.Errorf("unable to send cancel to channel FSM: %w", err)
}

return m.channels.Cancel(chid)
return nil
}

// pause a running data transfer channel
Expand Down

0 comments on commit b9b87cb

Please sign in to comment.