Skip to content

Commit

Permalink
Merge pull request #304 from SiaFoundation/chris/goleak
Browse files Browse the repository at this point in the history
Close registry recorder on shutdown
  • Loading branch information
n8maninger committed Feb 13, 2024
2 parents 682de09 + f77a441 commit 144e896
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions cmd/hostd/node.go
Expand Up @@ -55,6 +55,7 @@ func (n *node) Close() error {
n.rhp3.Close()
n.rhp2.Close()
n.data.Close()
n.registry.Close()
n.storage.Close()
n.contracts.Close()
n.w.Close()
Expand Down
1 change: 1 addition & 0 deletions go.mod
Expand Up @@ -14,6 +14,7 @@ require (
go.sia.tech/renterd v0.6.0
go.sia.tech/siad v1.5.10-0.20230228235644-3059c0b930ca
go.sia.tech/web/hostd v0.37.0
go.uber.org/goleak v1.2.0
go.uber.org/zap v1.26.0
golang.org/x/sys v0.16.0
golang.org/x/term v0.16.0
Expand Down
1 change: 1 addition & 0 deletions go.sum
Expand Up @@ -277,6 +277,7 @@ golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1m
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 h1:VLliZ0d+/avPrXXH+OakdXhpJuEoBZuwh1m2j7U6Iug=
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc=
Expand Down
5 changes: 5 additions & 0 deletions host/contracts/revenue_test.go
Expand Up @@ -14,10 +14,15 @@ import (
"go.sia.tech/hostd/internal/test"
rhp3 "go.sia.tech/hostd/internal/test/rhp/v3"
"go.sia.tech/hostd/persist/sqlite"
"go.uber.org/goleak"
"go.uber.org/zap/zaptest"
"lukechampine.com/frand"
)

func TestMain(m *testing.M) {
goleak.VerifyTestMain(m)
}

func checkRevenueConsistency(s *sqlite.Store, potential, earned metrics.Revenue) error {
time.Sleep(time.Second) // commit time

Expand Down
6 changes: 5 additions & 1 deletion host/registry/registry.go
Expand Up @@ -122,6 +122,10 @@ func NewManager(privkey types.PrivateKey, store Store, log *zap.Logger) *Manager
log: log.Named("recorder"),
},
}
go m.recorder.Run(m.tg.Done())
done, _ := m.tg.Add()
go func() {
m.recorder.Run(m.tg.Done())
done()
}()
return m
}
1 change: 1 addition & 0 deletions internal/test/host.go
Expand Up @@ -84,6 +84,7 @@ func (h *Host) Close() error {
h.settings.Close()
h.wallet.Close()
h.contracts.Close()
h.registry.Close()
h.storage.Close()
h.store.Close()
h.Node.Close()
Expand Down
5 changes: 5 additions & 0 deletions rhp/v2/rpc_test.go
Expand Up @@ -13,10 +13,15 @@ import (
"go.sia.tech/core/types"
"go.sia.tech/hostd/internal/test"
"go.sia.tech/renterd/wallet"
"go.uber.org/goleak"
"go.uber.org/zap/zaptest"
"lukechampine.com/frand"
)

func TestMain(m *testing.M) {
goleak.VerifyTestMain(m)
}

func TestSettings(t *testing.T) {
log := zaptest.NewLogger(t)
renter, host, err := test.NewTestingPair(t.TempDir(), log)
Expand Down
5 changes: 5 additions & 0 deletions rhp/v3/websocket_test.go
Expand Up @@ -7,10 +7,15 @@ import (

rhp3 "go.sia.tech/core/rhp/v3"
"go.sia.tech/hostd/internal/test"
"go.uber.org/goleak"
"go.uber.org/zap/zaptest"
"nhooyr.io/websocket"
)

func TestMain(m *testing.M) {
goleak.VerifyTestMain(m)
}

func TestWebSockets(t *testing.T) {
log := zaptest.NewLogger(t)
renter, host, err := test.NewTestingPair(t.TempDir(), log)
Expand Down

0 comments on commit 144e896

Please sign in to comment.