Skip to content
This repository has been archived by the owner on May 26, 2022. It is now read-only.

Fix logging race #100

Merged
merged 2 commits into from
Feb 4, 2019
Merged

Fix logging race #100

merged 2 commits into from
Feb 4, 2019

Conversation

anacrolix
Copy link
Contributor

Fix race caused by log statement. Merge #99 to see its effect.

@anacrolix anacrolix requested a review from raulk February 4, 2019 04:21
@ghost ghost assigned anacrolix Feb 4, 2019
@ghost ghost added the status/in-progress In progress label Feb 4, 2019
limiter.go Outdated
log.Debugf("[limiter] executing dial (dialfunc); peer: %s; addr: %s; FD consuming: %d; waiting: %d",
j.peer, j.addr, dl.fdConsuming, len(dl.waitingOnFd))
dl.lk.Unlock()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the race here? log should be thread-safe.

@raulk
Copy link
Member

raulk commented Feb 4, 2019

I’m ok with this data race. It’s not worthwhile to sync for a log that does not require consistency and that will not be printed in 99% of cases (debug). Even if we sync’ed, it would not have a visible effect. Any way to quieten the race checker? Reopen if you think this is a mistake.

@raulk raulk closed this Feb 4, 2019
@ghost ghost removed the status/in-progress In progress label Feb 4, 2019
@Kubuxu
Copy link
Member

Kubuxu commented Feb 4, 2019

Unfortunately, there is no way to quiet the racechecker. Maybe we should just remove the log, the dial will be logged esewhere.

@raulk
Copy link
Member

raulk commented Feb 4, 2019

@Kubuxu I'm not one to remove logs, but it's justified in this case because this statement is actually superfluous. The original one is here: https://github.com/libp2p/go-libp2p-swarm/blob/master/limiter.go#L162, and we trust Go enough to launch the goroutine. So this statement adds no value.

@raulk raulk reopened this Feb 4, 2019
@ghost ghost assigned raulk Feb 4, 2019
@ghost ghost added the status/in-progress In progress label Feb 4, 2019
@Kubuxu Kubuxu merged commit 65dbfb6 into master Feb 4, 2019
@ghost ghost removed the status/in-progress In progress label Feb 4, 2019
@raulk raulk deleted the fix-logging-race branch February 4, 2019 18:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants