Skip to content

Commit

Permalink
Merge pull request #98 from leslie-qiwa/master
Browse files Browse the repository at this point in the history
socket should be closed when socket error happened during abort
  • Loading branch information
pin authored Jan 7, 2025
2 parents 4cdfefc + 7416aa1 commit f723ab0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,12 @@ func (r *receiver) abort(err error) error {
if r.conn == nil {
return nil
}

defer func() {
r.conn.close()
r.conn = nil
}()

if r.hook != nil {
r.hook.OnFailure(r.buildTransferStats(), err)
}
Expand All @@ -266,7 +272,5 @@ func (r *receiver) abort(err error) error {
if err != nil {
return err
}
r.conn.close()
r.conn = nil
return nil
}
8 changes: 6 additions & 2 deletions sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,12 @@ func (s *sender) abort(err error) error {
if s.conn == nil {
return nil
}

defer func() {
s.conn.close()
s.conn = nil
}()

if s.hook != nil {
s.hook.OnFailure(s.buildTransferStats(), err)
}
Expand All @@ -286,7 +292,5 @@ func (s *sender) abort(err error) error {
if err != nil {
return err
}
s.conn.close()
s.conn = nil
return nil
}

0 comments on commit f723ab0

Please sign in to comment.