File tree Expand file tree Collapse file tree 4 files changed +18
-10
lines changed Expand file tree Collapse file tree 4 files changed +18
-10
lines changed Original file line number Diff line number Diff line change @@ -205,7 +205,10 @@ loop:
205
205
// tell the pool to shutdown.
206
206
q .baseCtxCancel ()
207
207
return
208
- case data := <- q .dataChan :
208
+ case data , ok := <- q .dataChan :
209
+ if ! ok {
210
+ return
211
+ }
209
212
if err := q .PushBack (data ); err != nil {
210
213
log .Error ("Unable to push back data into queue %s" , q .name )
211
214
}
Original file line number Diff line number Diff line change @@ -117,7 +117,10 @@ func (q *ChannelQueue) FlushWithContext(ctx context.Context) error {
117
117
select {
118
118
case <- paused :
119
119
return nil
120
- case data := <- q .dataChan :
120
+ case data , ok := <- q .dataChan :
121
+ if ! ok {
122
+ return nil
123
+ }
121
124
if unhandled := q .handle (data ); unhandled != nil {
122
125
log .Error ("Unhandled Data whilst flushing queue %d" , q .qid )
123
126
}
Original file line number Diff line number Diff line change @@ -178,7 +178,10 @@ func (q *ChannelUniqueQueue) FlushWithContext(ctx context.Context) error {
178
178
default :
179
179
}
180
180
select {
181
- case data := <- q .dataChan :
181
+ case data , ok := <- q .dataChan :
182
+ if ! ok {
183
+ return nil
184
+ }
182
185
if unhandled := q .handle (data ); unhandled != nil {
183
186
log .Error ("Unhandled Data whilst flushing queue %d" , q .qid )
184
187
}
Original file line number Diff line number Diff line change @@ -282,13 +282,12 @@ func (q *PersistableChannelUniqueQueue) Shutdown() {
282
282
q .channelQueue .Wait ()
283
283
q .internal .(* LevelUniqueQueue ).Wait ()
284
284
// Redirect all remaining data in the chan to the internal channel
285
- go func () {
286
- log .Trace ("PersistableChannelUniqueQueue: %s Redirecting remaining data" , q .delayedStarter .name )
287
- for data := range q .channelQueue .dataChan {
288
- _ = q .internal .Push (data )
289
- }
290
- log .Trace ("PersistableChannelUniqueQueue: %s Done Redirecting remaining data" , q .delayedStarter .name )
291
- }()
285
+ close (q .channelQueue .dataChan )
286
+ log .Trace ("PersistableChannelUniqueQueue: %s Redirecting remaining data" , q .delayedStarter .name )
287
+ for data := range q .channelQueue .dataChan {
288
+ _ = q .internal .Push (data )
289
+ }
290
+ log .Trace ("PersistableChannelUniqueQueue: %s Done Redirecting remaining data" , q .delayedStarter .name )
292
291
293
292
log .Debug ("PersistableChannelUniqueQueue: %s Shutdown" , q .delayedStarter .name )
294
293
}
You can’t perform that action at this time.
0 commit comments