Skip to content

Commit 9d4832e

Browse files
Only close the channel once
1 parent a73224d commit 9d4832e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

driver/sql/projection_notification_processor.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ func (b *ProjectionNotificationProcessor) startProcessor(ctx context.Context, ha
143143
// provided ProcessHandler it's first call and related messages are finished or when the context is done.
144144
func (b *ProjectionNotificationProcessor) wrapProcessHandlerForSingleRun(handler ProcessHandler) (ProcessHandler, chan struct{}) {
145145
done := make(chan struct{})
146+
var doneOnce sync.Once
146147

147148
var m sync.Mutex
148149
var triggers int32
@@ -165,11 +166,15 @@ func (b *ProjectionNotificationProcessor) wrapProcessHandlerForSingleRun(handler
165166
case <-done:
166167
case <-ctx.Done():
167168
// Context is expired
168-
close(done)
169+
doneOnce.Do(func() {
170+
close(done)
171+
})
169172
default:
170173
// No more queued messages to close the run
171174
if b.notificationQueue.Empty() {
172-
close(done)
175+
doneOnce.Do(func() {
176+
close(done)
177+
})
173178
}
174179
}
175180
}()

0 commit comments

Comments
 (0)