Skip to content

Commit

Permalink
Merge pull request #26 from matubu/feat/mdns_restart
Browse files Browse the repository at this point in the history
fix: check if context is expired inside WaitForStageChange (netmanager)
  • Loading branch information
gfanton authored Mar 29, 2023
2 parents 903d445 + 0b05349 commit 8d3f3fb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/netmanager/netmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,12 @@ func (m *NetManager) UpdateState(state ConnectivityInfo) {
// A true value is returned in former case and false in latter.
// The EventType is also returned to know which events has been triggered.
func (m *NetManager) WaitForStateChange(ctx context.Context, sourceState *ConnectivityInfo, eventType EventType) (bool, EventType) {
if ctx.Err() != nil {
return false, 0
}

m.locker.Lock()
defer m.locker.Unlock()

var currentEventType EventType
ok := true
Expand Down Expand Up @@ -90,7 +95,6 @@ func (m *NetManager) WaitForStateChange(ctx context.Context, sourceState *Connec
ok = m.notify.Wait(ctx)
}

m.locker.Unlock()
return ok, currentEventType
}

Expand Down

0 comments on commit 8d3f3fb

Please sign in to comment.