mirror of
https://github.com/netbirdio/netbird.git
synced 2026-10-05 04:59:06 +02:00
fix(engine): avoid deadlock when stopping engine during debug bundle
This commit is contained in:
@@ -927,12 +927,16 @@ func (e *Engine) receiveJobEvents() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (e *Engine) handleBundle(params *mgmProto.BundleParameters) (*mgmProto.JobResponse_Bundle, error) {
|
func (e *Engine) handleBundle(params *mgmProto.BundleParameters) (*mgmProto.JobResponse_Bundle, error) {
|
||||||
// todo: @Vic, do we need to latest sync response all the time here or could it be nil in the debug bundle?
|
// Access sync response directly without calling exported method to avoid deadlock
|
||||||
// todo: e.GetLatestSyncResponse() is exported and has been protected by a mutex. If you will use handleBundle in
|
// This is safe because we're in a goroutine that doesn't hold the syncMsgMux
|
||||||
// also protected context then will be deadlock
|
var syncResponse *mgmProto.SyncResponse
|
||||||
syncResponse, err := e.GetLatestSyncResponse()
|
if e.persistSyncResponse && e.latestSyncResponse != nil {
|
||||||
if err != nil {
|
log.Debugf("Retrieving latest sync response with size %d bytes", proto.Size(e.latestSyncResponse))
|
||||||
return nil, fmt.Errorf("get latest sync response: %w", err)
|
if sr, ok := proto.Clone(e.latestSyncResponse).(*mgmProto.SyncResponse); ok {
|
||||||
|
syncResponse = sr
|
||||||
|
} else {
|
||||||
|
return nil, fmt.Errorf("failed to clone sync response")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if syncResponse == nil {
|
if syncResponse == nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user