Prevent Peer Queue Close from being called more than Once on Shutdown
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Sarah Jamie Lewis 2022-11-30 14:13:54 -08:00 committed by Gitea
parent c8a6a1b079
commit 321b08bfd3
3 changed files with 14 additions and 6 deletions

View File

@ -48,8 +48,10 @@ func (iq *queue) Len() int {
// Shutdown closes our eventChannel
func (iq *queue) Shutdown() {
iq.lock.Lock()
if !iq.closed {
iq.closed = true
iq.infChan.Close()
}
iq.lock.Unlock()
}

View File

@ -1124,11 +1124,14 @@ func (cp *cwtchPeer) StartServerConnections() {
func (cp *cwtchPeer) Shutdown() {
cp.mutex.Lock()
defer cp.mutex.Unlock()
// don't allow this to be shutdown twice...
if !cp.shutdown {
cp.shutdown = true
cp.queue.Shutdown()
if cp.storage != nil {
cp.storage.Close(true)
}
}
}
func (cp *cwtchPeer) storeMessage(handle string, message string, sent time.Time) (int, error) {

View File

@ -157,6 +157,9 @@ func TestFileSharing(t *testing.T) {
// run the same download test again...to check that we can actually download the file
testBobDownloadFile(t, bob, filesharingFunctionality, queueOracle)
// test that we can delete bob...
app.DeletePeer(bob.GetOnion(), "asdfasdf")
queueOracle.Shutdown()
app.Shutdown()
acn.Close()