Skip to content

Commit c421290

Browse files
committed
test ci
1 parent e844cac commit c421290

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

pkg/controller/source/source.go

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,23 @@ func (cs *ChannelSource) Start(
115115
select {
116116
case <-cs.stop:
117117
// Close destination channels
118-
cs.doStop()
118+
cs.destLock.Lock()
119+
for _, dst := range cs.dest {
120+
close(dst)
121+
}
122+
cs.destLock.Unlock()
119123
return
120124
case evt := <-cs.Source:
121-
cs.distribute(evt)
125+
cs.destLock.Lock()
126+
for _, dst := range cs.dest {
127+
// We cannot make it under goroutine here, or we'll meet the
128+
// race condition of writing message to closed channels.
129+
// To avoid blocking, the dest channels are expected to be of
130+
// proper buffer size. If we still see it blocked, then
131+
// the controller is thought to be in an abnormal state.
132+
dst <- evt
133+
}
134+
cs.destLock.Unlock()
122135
}
123136
}
124137
}()
@@ -149,6 +162,7 @@ func (cs *ChannelSource) Start(
149162
return nil
150163
}
151164

165+
/*
152166
func (cs *ChannelSource) doStop() {
153167
cs.destLock.Lock()
154168
defer cs.destLock.Unlock()
@@ -157,7 +171,9 @@ func (cs *ChannelSource) doStop() {
157171
close(dst)
158172
}
159173
}
174+
*/
160175

176+
/*
161177
func (cs *ChannelSource) distribute(evt event.GenericEvent) {
162178
cs.destLock.Lock()
163179
defer cs.destLock.Unlock()
@@ -171,6 +187,7 @@ func (cs *ChannelSource) distribute(evt event.GenericEvent) {
171187
dst <- evt
172188
}
173189
}
190+
*/
174191

175192
// KindSource is used to provide a source of events originating inside the cluster from Watches (eh.g. Pod Create)
176193
type KindSource struct {

0 commit comments

Comments
 (0)