Skip to content

Commit

Permalink
Tidying Manager
Browse files Browse the repository at this point in the history
  • Loading branch information
ayuryshev committed May 30, 2019
1 parent 9930b57 commit 529d486
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions pkg/transport/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@ type Manager struct {
transports map[uuid.UUID]*ManagedTransport
entries map[Entry]struct{}

isClosing bool
doneChan chan struct{}
TrChan chan *ManagedTransport
mu sync.RWMutex
doneChan chan struct{}
TrChan chan *ManagedTransport
mu sync.RWMutex
}

// NewManager creates a Manager with the provided configuration and transport factories.
Expand Down Expand Up @@ -256,9 +255,6 @@ func (tm *Manager) DeleteTransport(id uuid.UUID) error {

// Close closes opened transports and registered factories.
func (tm *Manager) Close() error {
for _, f := range tm.factories {
f.Close()
}

close(tm.doneChan)

Expand All @@ -273,13 +269,16 @@ func (tm *Manager) Close() error {

tr.Close()
}
tm.transports = make(map[uuid.UUID]*ManagedTransport)
tm.mu.Unlock()

if _, err := tm.config.DiscoveryClient.UpdateStatuses(context.Background(), statuses...); err != nil {
tm.Logger.Warnf("Failed to change transport status: %s", err)
}

for _, f := range tm.factories {
go f.Close()
}

return nil
}

Expand Down

0 comments on commit 529d486

Please sign in to comment.