Prevent Peer Queue Close from being called more than Once on Shutdown
continuous-integration/drone/pr Build is passing
Details
continuous-integration/drone/pr Build is passing
Details
This commit is contained in:
parent
9ef244bc80
commit
c8c6b38810
|
@ -48,8 +48,10 @@ func (iq *queue) Len() int {
|
||||||
// Shutdown closes our eventChannel
|
// Shutdown closes our eventChannel
|
||||||
func (iq *queue) Shutdown() {
|
func (iq *queue) Shutdown() {
|
||||||
iq.lock.Lock()
|
iq.lock.Lock()
|
||||||
iq.closed = true
|
if !iq.closed {
|
||||||
iq.infChan.Close()
|
iq.closed = true
|
||||||
|
iq.infChan.Close()
|
||||||
|
}
|
||||||
iq.lock.Unlock()
|
iq.lock.Unlock()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1035,10 +1035,13 @@ func (cp *cwtchPeer) StartServerConnections() {
|
||||||
func (cp *cwtchPeer) Shutdown() {
|
func (cp *cwtchPeer) Shutdown() {
|
||||||
cp.mutex.Lock()
|
cp.mutex.Lock()
|
||||||
defer cp.mutex.Unlock()
|
defer cp.mutex.Unlock()
|
||||||
cp.shutdown = true
|
// don't allow this to be shutdown twice...
|
||||||
cp.queue.Shutdown()
|
if !cp.shutdown {
|
||||||
if cp.storage != nil {
|
cp.shutdown = true
|
||||||
cp.storage.Close(true)
|
cp.queue.Shutdown()
|
||||||
|
if cp.storage != nil {
|
||||||
|
cp.storage.Close(true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -394,7 +394,7 @@ func TestCwtchPeerIntegration(t *testing.T) {
|
||||||
pprof.Lookup("goroutine").WriteTo(os.Stdout, 1)
|
pprof.Lookup("goroutine").WriteTo(os.Stdout, 1)
|
||||||
|
|
||||||
log.Infof("numGoRoutinesStart: %v\nnumGoRoutinesPostAppStart: %v\nnumGoRoutinesPostPeerStart: %v\nnumGoRoutinesPostPeerAndServerConnect: %v\n"+
|
log.Infof("numGoRoutinesStart: %v\nnumGoRoutinesPostAppStart: %v\nnumGoRoutinesPostPeerStart: %v\nnumGoRoutinesPostPeerAndServerConnect: %v\n"+
|
||||||
"numGoRoutinesPostAlice: %v\nnumGoRoutinesPostCarolConnect: %v\nnumGoRoutinesPostBob: %v\nnumGoRoutinesPostCarol: %v\nnumGoRoutinesPostAppShutdown: %v",
|
"numGoRoutinesPostAlice: %v\nnumGoRoutinesPostCarolConnect: %v\nnumGoRoutinesPostBob: %v\nnumGoRoutinesPostCarol: %v\nnumGoRoutinesPostAppShutdown: %v",
|
||||||
numGoRoutinesStart, numGoRoutinesPostAppStart, numGoRoutinesPostPeerStart, numGoRoutinesPostServerConnect,
|
numGoRoutinesStart, numGoRoutinesPostAppStart, numGoRoutinesPostPeerStart, numGoRoutinesPostServerConnect,
|
||||||
numGoRoutinesPostAlice, numGoRoutinesPostCarolConnect, numGoRoutinesPostBob, numGoRoutinesPostCarol, numGoRoutinesPostAppShutdown)
|
numGoRoutinesPostAlice, numGoRoutinesPostCarolConnect, numGoRoutinesPostBob, numGoRoutinesPostCarol, numGoRoutinesPostAppShutdown)
|
||||||
|
|
||||||
|
|
|
@ -157,6 +157,9 @@ func TestFileSharing(t *testing.T) {
|
||||||
// run the same download test again...to check that we can actually download the file
|
// run the same download test again...to check that we can actually download the file
|
||||||
testBobDownloadFile(t, bob, filesharingFunctionality, queueOracle)
|
testBobDownloadFile(t, bob, filesharingFunctionality, queueOracle)
|
||||||
|
|
||||||
|
// test that we can delete bob...
|
||||||
|
app.DeletePeer(bob.GetOnion(), "asdfasdf")
|
||||||
|
|
||||||
queueOracle.Shutdown()
|
queueOracle.Shutdown()
|
||||||
app.Shutdown()
|
app.Shutdown()
|
||||||
acn.Close()
|
acn.Close()
|
||||||
|
|
Loading…
Reference in New Issue