[management] fix some concurrency potential issues (#5584)

This commit is contained in:
Vlad
2026-03-12 15:57:36 +01:00
committed by GitHub
parent d3d6a327e0
commit 8f389fef19
4 changed files with 38 additions and 12 deletions

View File

@@ -28,7 +28,13 @@ func NewChannel() *Channel {
return jc
}
func (jc *Channel) AddEvent(ctx context.Context, responseWait time.Duration, event *Event) error {
func (jc *Channel) AddEvent(ctx context.Context, responseWait time.Duration, event *Event) (err error) {
defer func() {
if r := recover(); r != nil {
err = ErrJobChannelClosed
}
}()
select {
case <-ctx.Done():
return ctx.Err()