Skip to content

Commit 1c8a60a

Browse files
committed
fix(eventbus): block drainer start after shutdown begins
1 parent 4923608 commit 1c8a60a

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

pkg/core/events/component.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ func (b *eventBus) Start(_ runtime.Runtime, _ <-chan struct{}) error {
9292
func (b *eventBus) Subscribe(subscriber Subscriber) error {
9393
b.rwMutex.Lock()
9494
defer b.rwMutex.Unlock()
95+
if b.stopped.Load() {
96+
return fmt.Errorf("eventBus already stopped")
97+
}
9598
rk := subscriber.ResourceKind()
9699
states, exists := b.subscriberDir[rk]
97100
if !exists {
@@ -216,6 +219,9 @@ func (b *eventBus) WaitForDone() {
216219
}
217220

218221
func (b *eventBus) launchDrainer(st *subscriberState) {
222+
if b.stopped.Load() {
223+
return
224+
}
219225
if !st.drainerStarted.CompareAndSwap(false, true) {
220226
return
221227
}

0 commit comments

Comments
 (0)