Merge pull request 'add locks to avoid possible race condition using command port' (#2) from locks2 into master

This commit is contained in:
Sarah Jamie Lewis 2020-05-08 16:33:16 -07:00
commit 42033f9819
1 changed files with 4 additions and 0 deletions

View File

@ -87,7 +87,9 @@ func (tp *torProvider) GetBootstrapStatus() (int, string) {
return -1, "Network Down"
}
tp.lock.Lock()
kvs, err := tp.t.Control.GetInfo("status/bootstrap-phase")
tp.lock.Unlock()
if err != nil {
return -2, "error querrying status/bootstrap-phase"
}
@ -122,6 +124,8 @@ func (tp *torProvider) WaitTillBootstrapped() {
// getNetworkStatus returns tor's beleif in the underlying network's status
func (tp *torProvider) getNetworkStatus() int {
tp.lock.Lock()
defer tp.lock.Unlock()
if tp.t == nil {
return networkDown
}