Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2022-08-11 09:49:55 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2022-09-21 17:22:38 +0300
commit1b451502195958057db2824518d559a8b63094f5 (patch)
tree5b1e69ad72f20d526f05050757bcb231cb873e4e
parentb6a7dd5bc4a314bf391ee336a451f6f0da0c8ff4 (diff)
sidechannel: Check error code when closing Unix socket listener
Check the error code when closing the Unix socket listener and drop the corresponding exclude from our linting rules.
-rw-r--r--.golangci.yml1
-rw-r--r--internal/gitaly/hook/sidechannel.go15
2 files changed, 13 insertions, 3 deletions
diff --git a/.golangci.yml b/.golangci.yml
index b86dc3e55..36368721c 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -71,7 +71,6 @@ linters-settings:
- (*google.golang.org/grpc.ServerConn).Close
- (*io.PipeReader).Close
- (*io.PipeWriter).Close
- - (*net.UnixConn).Close
- (*os.File).Close
- (io.Closer).Close
- (io/fs.File).Close
diff --git a/internal/gitaly/hook/sidechannel.go b/internal/gitaly/hook/sidechannel.go
index 62c32a059..14fa5304e 100644
--- a/internal/gitaly/hook/sidechannel.go
+++ b/internal/gitaly/hook/sidechannel.go
@@ -107,7 +107,10 @@ func (wt *SidechannelWaiter) run(callback func(*net.UnixConn) error) {
if err != nil {
return err
}
- defer c.Close()
+ defer func() {
+ // Error is already checked below.
+ _ = c.Close()
+ }()
// Eagerly remove the socket directory, in case the process exits before
// wt.Close() can run.
@@ -115,7 +118,15 @@ func (wt *SidechannelWaiter) run(callback func(*net.UnixConn) error) {
return err
}
- return callback(c)
+ if err := callback(c); err != nil {
+ return err
+ }
+
+ if err := c.Close(); err != nil {
+ return err
+ }
+
+ return nil
}()
}