Skip to content

Commit

Permalink
Check listener-close error
Browse files Browse the repository at this point in the history
  • Loading branch information
srebhan committed Jul 17, 2024
1 parent f3efc44 commit 8dba089
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions plugins/common/socket/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,11 @@ func (l *streamListener) address() net.Addr {

func (l *streamListener) close() error {
if l.listener != nil {
l.listener.Close()
// Continue even if we cannot close the listener in order to at least
// close all active connections
if err := l.listener.Close(); err != nil {
l.Log.Errorf("Cannot close listener: %v", err)
}
}

if l.cancel != nil {
Expand All @@ -207,8 +211,8 @@ func (l *streamListener) close() error {
if runtime.GOOS == "windows" && strings.Contains(fn, ":") {
fn = strings.TrimPrefix(fn, `\`)
}
// Ignore file-not-exists errors when removing the socket
if err := os.Remove(fn); err != nil && !errors.Is(err, os.ErrNotExist) {
// Ignore file-not-exists errors when removing the socket
return err
}
}
Expand Down

0 comments on commit 8dba089

Please sign in to comment.