forked from openprivacy/connectivity
add locks to acoid possible race condition using command port
This commit is contained in:
parent
f903fd4c8f
commit
4eedeaa4db
|
@ -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