From 6f3672df4f06d1818598f7fbcf29c15a7aa239b8 Mon Sep 17 00:00:00 2001 From: Riccardo Biraghi Date: Mon, 9 Apr 2018 15:50:12 +0100 Subject: [PATCH] Apply mirroring delay to last iteration --- cmd/runmqserver/mirror.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/runmqserver/mirror.go b/cmd/runmqserver/mirror.go index 170e608..d58ad71 100644 --- a/cmd/runmqserver/mirror.go +++ b/cmd/runmqserver/mirror.go @@ -171,8 +171,8 @@ func mirrorLog(ctx context.Context, wg *sync.WaitGroup, path string, fromStart b // Don't seek this time, because we know it's a new file mirrorAvailableMessages(f, mf) } - select { - case <-ctx.Done(): + + if <-ctx.Done() { log.Debugf("Context cancelled for mirroring %v", path) if closing { log.Debugf("Shutting down mirror for %v", path) @@ -180,9 +180,9 @@ func mirrorLog(ctx context.Context, wg *sync.WaitGroup, path string, fromStart b } // Set a flag, to allow one more time through the loop closing = true - default: - time.Sleep(500 * time.Millisecond) } + + time.Sleep(500 * time.Millisecond) } }() return errorChannel, nil