Add Lock to ReplaceACN. Minor Drone fixups
This commit is contained in:
parent
13045e3d98
commit
5d4cf85d26
|
@ -14,7 +14,6 @@ pipeline:
|
||||||
- wget https://git.openprivacy.ca/openprivacy/buildfiles/raw/master/tor/tor -P tmp/
|
- wget https://git.openprivacy.ca/openprivacy/buildfiles/raw/master/tor/tor -P tmp/
|
||||||
- chmod a+x tmp/tor
|
- chmod a+x tmp/tor
|
||||||
- go mod download
|
- go mod download
|
||||||
- go get -u
|
|
||||||
quality:
|
quality:
|
||||||
when:
|
when:
|
||||||
repo: openprivacy/connectivity
|
repo: openprivacy/connectivity
|
||||||
|
|
|
@ -4,5 +4,4 @@ tor/tor/
|
||||||
vendor/
|
vendor/
|
||||||
*.cover.out
|
*.cover.out
|
||||||
tmp/
|
tmp/
|
||||||
testing/tor/torrc
|
|
||||||
testing/tor/*
|
testing/tor/*
|
|
@ -2,6 +2,7 @@ package connectivity
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
||||||
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ProxyACN because there is rarely a problem that can't be solved by another layer of indirection.
|
// ProxyACN because there is rarely a problem that can't be solved by another layer of indirection.
|
||||||
|
@ -11,6 +12,10 @@ import (
|
||||||
// ProxyACN - a wrapper around an ACN that allows safe replacement of a running ACN that is transparent to callers.
|
// ProxyACN - a wrapper around an ACN that allows safe replacement of a running ACN that is transparent to callers.
|
||||||
type ProxyACN struct {
|
type ProxyACN struct {
|
||||||
acn ACN
|
acn ACN
|
||||||
|
|
||||||
|
// All operations on the underlying acn are assumed to be thread safe, however changing the actual
|
||||||
|
// acn in ReplaceACN will lock to force an ordering of Close and Callback
|
||||||
|
lock sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewProxyACN(acn ACN) ProxyACN {
|
func NewProxyACN(acn ACN) ProxyACN {
|
||||||
|
@ -21,6 +26,8 @@ func NewProxyACN(acn ACN) ProxyACN {
|
||||||
|
|
||||||
// ReplaceACN closes down the current ACN and replaces it with a new ACN.
|
// ReplaceACN closes down the current ACN and replaces it with a new ACN.
|
||||||
func (p *ProxyACN) ReplaceACN(acn ACN) {
|
func (p *ProxyACN) ReplaceACN(acn ACN) {
|
||||||
|
p.lock.Lock()
|
||||||
|
defer p.lock.Unlock()
|
||||||
p.acn.Close()
|
p.acn.Close()
|
||||||
acn.SetStatusCallback(p.acn.Callback())
|
acn.SetStatusCallback(p.acn.Callback())
|
||||||
p.acn = acn
|
p.acn = acn
|
||||||
|
|
Loading…
Reference in New Issue