The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/5118
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) === This commit fixes a potential race condition when listening for events and extracting operations by moving the lock to before the operation struct is created. For #5117
From e3d0bc690f47f5971bbf99d784b75737eacc28ca Mon Sep 17 00:00:00 2001 From: Joe Topjian <j...@topjian.net> Date: Tue, 9 Oct 2018 01:54:08 +0000 Subject: [PATCH] Fix Potential Event Race This commit fixes a potential race condition when listening for events and extracting operations by moving the lock to before the operation struct is created. --- client/operations.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client/operations.go b/client/operations.go index fc015c220c..f27df75b1a 100644 --- a/client/operations.go +++ b/client/operations.go @@ -152,16 +152,16 @@ func (op *operation) setupListener() error { _, err := op.listener.AddHandler([]string{"operation"}, func(data interface{}) { <-chReady + // We don't want concurrency while processing events + op.handlerLock.Lock() + defer op.handlerLock.Unlock() + // Get an operation struct out of this data newOp := op.extractOperation(data) if newOp == nil { return } - // We don't want concurrency while processing events - op.handlerLock.Lock() - defer op.handlerLock.Unlock() - // Check if we're done already (because of another event) if op.listener == nil { return
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel