Skip to content

Commit

Permalink
Fix context leaks (#975)
Browse files Browse the repository at this point in the history
  • Loading branch information
thom-at-redhat committed Mar 25, 2024
1 parent e32df9f commit dfde572
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 22 deletions.
20 changes: 0 additions & 20 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,19 @@ linters:
enable:
- asciicheck
- bodyclose
# - cyclop # TODO: Reduce code complexity.
- depguard
- dogsled
# - dupl # TODO: Remove duplicates.
- durationcheck
# - errcheck # TODO: Not all received errors are checked.
# - errorlint # TODO: Use errors package.
- exportloopref
# - forcetypeassert # TODO: always assert types when when casting.
# - funlen # TODO: Reduce code complexity.
- gci
# - gochecknoglobals # TODO: Reduce number of globals.
# - gochecknoinits # TODO: Maybe not use init().
# - gocognit # TODO: Reduce code complexity.
- gocritic
# - gocyclo # TODO: Reduce code complexity.
- godot
# - goerr113 # TODO: Please do not use dynamic errors.
- gofmt
- gofumpt
- goheader
- goimports
# - golint # Deprecated.
- gomoddirectives
- gomodguard
# - goprintffuncname # TODO: logging methods are not named like the ones in `fmt` which could lead to problems.
- gosec
- gosimple
- govet
Expand All @@ -41,29 +28,22 @@ linters:
- makezero
- misspell
- nakedret
# - nestif # TODO: Reduce code complexity.
- nilerr
- nlreturn
- noctx
- nolintlint
# - paralleltest # TODO: missing at some locations
- prealloc
- predeclared
# - revive
- rowserrcheck
- sqlclosecheck
- staticcheck
- stylecheck
# - testpackage # TODO: Put tests in their dedicated test packages.
# - thelper # TODO: Requires test refactoring.
- tparallel
- typecheck
- unconvert
# - unparam # TODO: This breaks something, look at it!
- unused
- wastedassign
- whitespace
# - wrapcheck # TODO: Errors passed upwards should be wrapped.

linters-settings:
depguard:
Expand Down
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/creack/pty v1.1.21 h1:1/QdRyBaHHJP61QkWMXlOIBfsgdDeeKfK8SYVUWJKf0=
github.com/creack/pty v1.1.21/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
Expand All @@ -8,6 +9,7 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g=
github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
github.com/evanphx/json-patch v4.12.0+incompatible h1:4onqiflcdA9EOZ4RxV643DvftH5pOlLGNtQ5lPWQu84=
github.com/evanphx/json-patch v4.12.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw=
github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g=
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
Expand Down Expand Up @@ -62,6 +64,7 @@ github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
Expand All @@ -84,9 +87,11 @@ github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+
github.com/onsi/ginkgo/v2 v2.13.2 h1:Bi2gGVkfn6gQcjNjZJVO8Gf0FHzMPf2phUei9tejVMs=
github.com/onsi/ginkgo/v2 v2.13.2/go.mod h1:XStQ8QcGwLyF4HdfcZB8SFOS/MWCgDuXMSBe6zrvLgM=
github.com/onsi/gomega v1.29.0 h1:KIA/t2t5UBzoirT4H9tsML45GEbo3ouUnBHsCfD2tVg=
github.com/onsi/gomega v1.29.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ=
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 h1:onHthvaw9LFnH4t2DcNVpwGmV9E1BkGknEliJkfwQj0=
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58/go.mod h1:DXv8WO4yhMYhSNPKjeNKa5WY9YCIEBRbNzFFPJbWO6Y=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prep/socketpair v0.0.0-20171228153254-c2c6a7f821c2 h1:vzKDZ0uNPcOdITzZT5d4Tn2YOalCMqIhYzVNq/oRjlw=
Expand All @@ -112,6 +117,7 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/vishvananda/netlink v1.1.0 h1:1iyaYNBLmP6L0220aDnYQpo1QEV4t4hJ+xEEhhJH8j0=
github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE=
github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU=
Expand Down
3 changes: 2 additions & 1 deletion pkg/netceptor/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ func (li *Listener) acceptLoop(ctx context.Context) {
continue
}
go func() {
ctx, _ := context.WithTimeout(ctx, 60*time.Second)
ctx, cancel := context.WithTimeout(ctx, 60*time.Second)
defer cancel()
qs, err := qc.AcceptStream(ctx)
select {
case <-li.doneChan:
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/mesh/work_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ func TestSignedWorkVerification(t *testing.T) {
t.Fatal(err, m.GetDataDir())
}

// node2 has the wrong public key to verify work signatures, so the work submission should fail
// node3 has the wrong public key to verify work signatures, so the work submission should fail
job = `{"command":"work","subcommand":"submit","worktype":"echo","node":"node3", "signwork":"true"}`
_, err = controllers["node1"].WorkSubmitJSON(job)
if err == nil {
Expand Down

0 comments on commit dfde572

Please sign in to comment.