mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-21 04:53:14 -06:00
Fix race condition
This commit is contained in:
parent
f4d6704d95
commit
333f0596dc
|
|
@ -24,6 +24,7 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"github.com/matrix-org/util"
|
"github.com/matrix-org/util"
|
||||||
|
|
||||||
|
|
@ -37,6 +38,7 @@ import (
|
||||||
// this unfortunately results in us adding the same hook multiple times.
|
// this unfortunately results in us adding the same hook multiple times.
|
||||||
// This map ensures we only ever add one level hook.
|
// This map ensures we only ever add one level hook.
|
||||||
var stdLevelLogAdded = make(map[logrus.Level]bool)
|
var stdLevelLogAdded = make(map[logrus.Level]bool)
|
||||||
|
var levelLogAddedMu = &sync.Mutex{}
|
||||||
|
|
||||||
type utcFormatter struct {
|
type utcFormatter struct {
|
||||||
logrus.Formatter
|
logrus.Formatter
|
||||||
|
|
|
||||||
|
|
@ -85,6 +85,8 @@ func checkSyslogHookParams(params map[string]interface{}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func setupStdLogHook(level logrus.Level) {
|
func setupStdLogHook(level logrus.Level) {
|
||||||
|
levelLogAddedMu.Lock()
|
||||||
|
defer levelLogAddedMu.Unlock()
|
||||||
if stdLevelLogAdded[level] {
|
if stdLevelLogAdded[level] {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue