Skip to content
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

Merged
merged 3 commits into from Jul 27, 2020
Merged

fix log data race #1263

merged 3 commits into from Jul 27, 2020

Conversation

laizy
Copy link
Contributor

@laizy laizy commented Jul 21, 2020

No description provided.

@laizy laizy requested a review from Honglei-Cong July 24, 2020 03:42
@@ -85,7 +87,19 @@ func GetGID() uint64 {
return n
}

var Log *Logger
var globalLogger unsafe.Pointer
Copy link
Member

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?

Copy link
Contributor Author

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.

func InitLog(logLevel int, a ...interface{}) {
logger := createLog(logLevel, a...)

swapGlobalLogger(logger)
Copy link
Member

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?

Copy link
Contributor Author

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 {
Copy link
Member

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.

Copy link
Contributor Author

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.

@Honglei-Cong
Copy link
Member

looks good to me.

@laizy laizy merged commit 9569d9a into ontio:master Jul 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants