From 6bf080393d88534aa658ecaff32ae089bd304772 Mon Sep 17 00:00:00 2001 From: Corey Hulen Date: Tue, 4 Apr 2017 11:42:07 -0700 Subject: Fixing race conditions in the code base (#5966) * Adding initial race detector * Remove setting of config twice * Fixing config file watch and config reload on license save * Fixing config file watch and config reload on license save * Fixing build error * Fixing locking issue * Fixing makefile * Fixing race in config * Fixing race in status unit test * Adding EE race tests * Fixing race in cluster info * Removing code that's isn't needed * Fixing some more races * Fixing govet issue --- vendor/github.com/alecthomas/log4go/filelog.go | 2 +- vendor/github.com/alecthomas/log4go/pattlog.go | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'vendor/github.com/alecthomas') diff --git a/vendor/github.com/alecthomas/log4go/filelog.go b/vendor/github.com/alecthomas/log4go/filelog.go index ee0ab0c04..9bc4df15f 100644 --- a/vendor/github.com/alecthomas/log4go/filelog.go +++ b/vendor/github.com/alecthomas/log4go/filelog.go @@ -47,7 +47,6 @@ func (w *FileLogWriter) LogWrite(rec *LogRecord) { func (w *FileLogWriter) Close() { close(w.rec) - w.file.Sync() } // NewFileLogWriter creates a new LogWriter which writes to the given file and @@ -79,6 +78,7 @@ func NewFileLogWriter(fname string, rotate bool) *FileLogWriter { defer func() { if w.file != nil { fmt.Fprint(w.file, FormatLogRecord(w.trailer, &LogRecord{Created: time.Now()})) + w.file.Sync() w.file.Close() } }() diff --git a/vendor/github.com/alecthomas/log4go/pattlog.go b/vendor/github.com/alecthomas/log4go/pattlog.go index 82b4e36b1..98632e4da 100644 --- a/vendor/github.com/alecthomas/log4go/pattlog.go +++ b/vendor/github.com/alecthomas/log4go/pattlog.go @@ -7,6 +7,7 @@ import ( "fmt" "io" "strings" + "sync" ) const ( @@ -22,6 +23,7 @@ type formatCacheType struct { } var formatCache = &formatCacheType{} +var mutex sync.Mutex // Known format codes: // %T - Time (15:04:05 MST) @@ -44,6 +46,7 @@ func FormatLogRecord(format string, rec *LogRecord) string { out := bytes.NewBuffer(make([]byte, 0, 64)) secs := rec.Created.UnixNano() / 1e9 + mutex.Lock() cache := *formatCache if cache.LastUpdateSeconds != secs { month, day, year := rec.Created.Month(), rec.Created.Day(), rec.Created.Year() @@ -59,6 +62,7 @@ func FormatLogRecord(format string, rec *LogRecord) string { cache = *updated formatCache = updated } + mutex.Unlock() // Split the string into pieces by % signs pieces := bytes.Split([]byte(format), []byte{'%'}) -- cgit v1.2.3-1-g7c22