mirror of
https://github.com/safing/portbase
synced 2025-09-01 01:59:48 +00:00
Use workers for module failure mirroring and fix mirror looping
This commit is contained in:
parent
5c87029991
commit
ae13d87aed
2 changed files with 13 additions and 5 deletions
|
@ -139,7 +139,7 @@ func (m *Module) setFailure(status uint8, id, title, msg string) {
|
||||||
|
|
||||||
// Propagate failure status.
|
// Propagate failure status.
|
||||||
if failureUpdateNotifyFuncReady.IsSet() {
|
if failureUpdateNotifyFuncReady.IsSet() {
|
||||||
m.newTask("failure status updater", func(context.Context, *Task) error {
|
m.RunWorker("failure status updater", func(context.Context) error {
|
||||||
// Only use data in worker that won't change anymore.
|
// Only use data in worker that won't change anymore.
|
||||||
|
|
||||||
// Resolve previous failure state if available.
|
// Resolve previous failure state if available.
|
||||||
|
@ -151,7 +151,7 @@ func (m *Module) setFailure(status uint8, id, title, msg string) {
|
||||||
failureUpdateNotifyFunc(status, id, title, msg)
|
failureUpdateNotifyFunc(status, id, title, msg)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}).QueuePrioritized()
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,11 +181,11 @@ func (m *Module) Resolve(failureID string) {
|
||||||
|
|
||||||
// Propagate failure status.
|
// Propagate failure status.
|
||||||
if failureUpdateNotifyFuncReady.IsSet() {
|
if failureUpdateNotifyFuncReady.IsSet() {
|
||||||
m.newTask("failure status updater", func(context.Context, *Task) error {
|
m.RunWorker("failure status updater", func(context.Context) error {
|
||||||
// Only use data in worker that won't change anymore.
|
// Only use data in worker that won't change anymore.
|
||||||
failureUpdateNotifyFunc(FailureNone, resolveFailureID, "", "")
|
failureUpdateNotifyFunc(FailureNone, resolveFailureID, "", "")
|
||||||
return nil
|
return nil
|
||||||
}).QueuePrioritized()
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,13 @@ func mirrorModuleStatus(moduleFailure uint8, id, title, msg string) {
|
||||||
// The notification already exists.
|
// The notification already exists.
|
||||||
|
|
||||||
// Check if we should delete it.
|
// Check if we should delete it.
|
||||||
if moduleFailure == modules.FailureNone {
|
if moduleFailure == modules.FailureNone && !n.Meta().IsDeleted() {
|
||||||
|
|
||||||
|
// Remove belongsTo, as the deletion was already triggered by the module itself.
|
||||||
|
n.Lock()
|
||||||
|
n.belongsTo = nil
|
||||||
|
n.Unlock()
|
||||||
|
|
||||||
n.Delete()
|
n.Delete()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,6 +98,8 @@ func mirrorModuleStatus(moduleFailure uint8, id, title, msg string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
switch moduleFailure {
|
switch moduleFailure {
|
||||||
|
case modules.FailureNone:
|
||||||
|
return
|
||||||
case modules.FailureHint:
|
case modules.FailureHint:
|
||||||
n.Type = Info
|
n.Type = Info
|
||||||
n.AvailableActions = nil
|
n.AvailableActions = nil
|
||||||
|
|
Loading…
Add table
Reference in a new issue