Skip to content

Commit

Permalink
Merge pull request #777 from i-hate-nicknames/fix/shutdown-data-races
Browse files Browse the repository at this point in the history
Fix/shutdown data races
  • Loading branch information
jdknives authored May 28, 2021
2 parents 4c2c618 + bc1c359 commit 56f7c36
Show file tree
Hide file tree
Showing 14 changed files with 692 additions and 98 deletions.
5 changes: 1 addition & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,21 @@ module github.com/skycoin/skywire
go 1.16

require (
github.com/AudriusButkevicius/pfilter v0.0.0-20190627213056-c55ef6137fc6
github.com/AudriusButkevicius/pfilter v0.0.0-20210515103320-4b4b86609d51
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d // indirect
github.com/VictoriaMetrics/metrics v1.12.3
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5
github.com/creack/pty v1.1.11 // indirect
github.com/go-chi/chi v4.1.2+incompatible
github.com/go-ole/go-ole v1.2.4 // indirect
github.com/golang/protobuf v1.4.2 // indirect
github.com/google/go-github v17.0.0+incompatible
github.com/google/go-querystring v1.0.0 // indirect
github.com/google/uuid v1.1.1
github.com/gorilla/securecookie v1.1.1
github.com/klauspost/reedsolomon v1.9.9 // indirect
github.com/mattn/go-colorable v0.1.8 // indirect
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
github.com/mholt/archiver/v3 v3.3.0
github.com/mmcloughlin/avo v0.0.0-20200523190732-4439b6b2c061 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pkg/profile v1.5.0
github.com/schollz/progressbar/v2 v2.15.0
github.com/shirou/gopsutil v2.20.5+incompatible
Expand Down
155 changes: 153 additions & 2 deletions go.sum

Large diffs are not rendered by default.

10 changes: 1 addition & 9 deletions pkg/router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ type router struct {
rpcSrv *rpc.Server
accept chan routing.EdgeRules
done chan struct{}
wg sync.WaitGroup
once sync.Once
}

Expand Down Expand Up @@ -318,12 +317,7 @@ func (r *router) Serve(ctx context.Context) error {

go r.serveTransportManager(ctx)

r.wg.Add(1)

go func() {
defer r.wg.Done()
r.serveSetup()
}()
go r.serveSetup()

r.tm.Serve(ctx)

Expand Down Expand Up @@ -745,8 +739,6 @@ func (r *router) Close() error {
r.logger.WithError(err).Warnf("closing route_manager returned error")
}

r.wg.Wait()

return r.tm.Close()
}

Expand Down
30 changes: 14 additions & 16 deletions pkg/snet/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,31 +268,29 @@ func (n *Network) Close() error {
}()
}

var directErrorsMu sync.Mutex
directErrors := make(map[string]error)
directErrors := make(chan error)

for k, v := range n.clients.Direct {
if v != nil {
wg.Add(1)
go func() {
err := v.Close()

directErrorsMu.Lock()
directErrors[k] = err
directErrorsMu.Unlock()

wg.Done()
}()
for _, directClient := range n.clients.Direct {
if directClient == nil {
continue
}
wg.Add(1)
go func(client directtp.Client) {
err := client.Close()
if err != nil {
directErrors <- err
}
wg.Done()
}(directClient)
}

wg.Wait()
close(directErrors)

if dmsgErr != nil {
return dmsgErr
}

for _, err := range directErrors {
for err := range directErrors {
if err != nil {
return err
}
Expand Down
5 changes: 2 additions & 3 deletions pkg/visor/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ import (
"sync"
"time"

"github.com/skycoin/dmsg"
dmsgnetutil "github.com/skycoin/dmsg/netutil"

"github.com/sirupsen/logrus"
"github.com/skycoin/dmsg"
"github.com/skycoin/dmsg/cipher"
"github.com/skycoin/dmsg/dmsgctrl"
dmsgnetutil "github.com/skycoin/dmsg/netutil"
"github.com/skycoin/skycoin/src/util/logging"

"github.com/skycoin/skywire/internal/utclient"
Expand Down
6 changes: 6 additions & 0 deletions pkg/visor/init_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

package visor

import (
"context"

"github.com/skycoin/skycoin/src/util/logging"
)

func initDmsgpty(ctx context.Context, log *logging.Logger) error {
log.Error("dmsgpty is not supported on windows.")
return nil
Expand Down
6 changes: 6 additions & 0 deletions vendor/github.com/AudriusButkevicius/pfilter/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 19 additions & 11 deletions vendor/github.com/AudriusButkevicius/pfilter/conn.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

69 changes: 69 additions & 0 deletions vendor/github.com/AudriusButkevicius/pfilter/conn_oob.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 56f7c36

Please sign in to comment.