forked from openprivacy/connectivity
Merge pull request 'add locks to avoid possible race condition using command port' (#2) from locks2 into master
This commit is contained in:
commit
42033f9819
|
@ -87,7 +87,9 @@ func (tp *torProvider) GetBootstrapStatus() (int, string) {
|
||||||
return -1, "Network Down"
|
return -1, "Network Down"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tp.lock.Lock()
|
||||||
kvs, err := tp.t.Control.GetInfo("status/bootstrap-phase")
|
kvs, err := tp.t.Control.GetInfo("status/bootstrap-phase")
|
||||||
|
tp.lock.Unlock()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return -2, "error querrying status/bootstrap-phase"
|
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
|
// getNetworkStatus returns tor's beleif in the underlying network's status
|
||||||
func (tp *torProvider) getNetworkStatus() int {
|
func (tp *torProvider) getNetworkStatus() int {
|
||||||
|
tp.lock.Lock()
|
||||||
|
defer tp.lock.Unlock()
|
||||||
if tp.t == nil {
|
if tp.t == nil {
|
||||||
return networkDown
|
return networkDown
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue