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
fix log data race #1263
fix log data race #1263
Conversation
@@ -85,7 +87,19 @@ func GetGID() uint64 { | |||
return n | |||
} | |||
|
|||
var Log *Logger | |||
var globalLogger unsafe.Pointer |
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.
validate pointer must not be nil after init?
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.
there is a init function to call InitLog, so can gurantee globalLogger will never be nil.
common/log/log.go
Outdated
func InitLog(logLevel int, a ...interface{}) { | ||
logger := createLog(logLevel, a...) | ||
|
||
swapGlobalLogger(logger) |
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.
It's public.
check if old-logger is nil, close it if not 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.
done
var Log *Logger | ||
var globalLogger unsafe.Pointer | ||
|
||
func Log() *Logger { |
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.
just a comment.
this function seems not necessary to be public.
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.
used in http rpc to set the log level.
looks good to me. |
No description provided.