docker: drain fingerprint timer

Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
This commit is contained in:
Yoan Blanc 2020-03-26 16:00:53 +01:00
parent ea80330aaa
commit 5f0b3234f0
No known key found for this signature in database
GPG key ID: 6058CF4574298812

View file

@ -61,6 +61,14 @@ func (d *Driver) fingerprintSuccessful() bool {
func (d *Driver) handleFingerprint(ctx context.Context, ch chan *drivers.Fingerprint) {
defer close(ch)
ticker := time.NewTimer(0)
defer func() {
// Ensures that the channel is empty by stopping and draining the ticker.
if !ticker.Stop() {
<-ticker.C
}
}()
for {
select {
case <-ctx.Done():