-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[bugfix] Improve handling of global and local mutexes to mitigate capture deadlocks #335
[bugfix] Improve handling of global and local mutexes to mitigate capture deadlocks #335
Conversation
@@ -44,57 +44,6 @@ var ( | |||
// providing the ability to override the default behavior, e.g. in mock tests | |||
type sourceInitFn func(*Capture) (Source, error) | |||
|
|||
// Captures denotes a named set of Capture instances, wrapping a map and the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just cleanup, moved to new file captures.go
below...
@@ -515,6 +519,10 @@ func (cm *Manager) rotate(ctx context.Context, writeoutChan chan<- capturetypes. | |||
// Lock the running capture in order to safely perform rotation tasks | |||
if err := mc.capLock.Lock(); err != nil { | |||
logger.Errorf("failed to establish rotation three-point lock: %s", err) | |||
if err := mc.close(); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was missing (I think because I was worried that we might end up with duplicate calls to close()
. However, this is now reasonably safe due to the additional capture Mutex.
@@ -560,17 +572,17 @@ func (cm *Manager) logErrors(ctx context.Context, iface string, errsChan <-chan | |||
|
|||
// Ensure there is no conflict with calls to update() that might already be | |||
// taking down this interface | |||
cm.Lock() | |||
defer cm.Unlock() | |||
cm.captures.Lock() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a tiny detail, but important. We lock the set of captures (because that's the only thin we potentially manipulate here) instead of the whole manager.
Closes #334