From cbc15ad4bf73568108c43d95050c9ad9a742ec47 Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Thu, 12 Oct 2023 16:37:06 +0900 Subject: [PATCH] cshared: Make non-blocking for checking existence of the channel Without using Mutex.TryLock(), this golang interface causes the main fluent-bit process stuck on pause. This shouldn't be desired behavior. Signed-off-by: Hiroshi Hatake --- cshared.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/cshared.go b/cshared.go index 2e6046d..fa8353b 100644 --- a/cshared.go +++ b/cshared.go @@ -92,7 +92,9 @@ func cleanup() int { runCancel = nil } - theInputLock.Lock() + if !theInputLock.TryLock() { + return input.FLB_OK + } defer theInputLock.Unlock() if theChannel != nil { @@ -258,7 +260,9 @@ func FLBPluginInputPause() { runCancel = nil } - theInputLock.Lock() + if !theInputLock.TryLock() { + return + } defer theInputLock.Unlock() if theChannel != nil { @@ -290,7 +294,9 @@ func FLBPluginOutputPreExit() { runCancel = nil } - theInputLock.Lock() + if !theInputLock.TryLock() { + return + } defer theInputLock.Unlock() if theChannel != nil {