This commit is contained in:
Jakob Borg 2023-05-25 09:47:40 +02:00
parent 734a8f5dee
commit 13742e6f09
3 changed files with 7 additions and 8 deletions

View File

@ -3096,13 +3096,6 @@ func (m *model) CommitConfiguration(from, to config.Configuration) bool {
} }
} }
// Removing a device. We actually don't need to do anything.
// Because folder config has changed (since the device lists do not match)
// Folders for that had device got "restarted", which involves killing
// connections to all devices that we were sharing the folder with.
// At some point model.Close() will get called for that device which will
// clean residue device state that is not part of any folder.
// Pausing a device, unpausing is handled by the connection service. // Pausing a device, unpausing is handled by the connection service.
fromDevices := from.DeviceMap() fromDevices := from.DeviceMap()
toDevices := to.DeviceMap() toDevices := to.DeviceMap()
@ -3138,6 +3131,7 @@ func (m *model) CommitConfiguration(from, to config.Configuration) bool {
m.setConnRequestLimiters(toCfg) m.setConnRequestLimiters(toCfg)
} }
} }
// Clean up after removed devices // Clean up after removed devices
removedDevices := make([]protocol.DeviceID, 0, len(fromDevices)) removedDevices := make([]protocol.DeviceID, 0, len(fromDevices))
m.fmut.Lock() m.fmut.Lock()

View File

@ -34,6 +34,7 @@ import (
"github.com/syncthing/syncthing/lib/osutil" "github.com/syncthing/syncthing/lib/osutil"
"github.com/syncthing/syncthing/lib/protocol" "github.com/syncthing/syncthing/lib/protocol"
protocolmocks "github.com/syncthing/syncthing/lib/protocol/mocks" protocolmocks "github.com/syncthing/syncthing/lib/protocol/mocks"
"github.com/syncthing/syncthing/lib/rand"
srand "github.com/syncthing/syncthing/lib/rand" srand "github.com/syncthing/syncthing/lib/rand"
"github.com/syncthing/syncthing/lib/testutils" "github.com/syncthing/syncthing/lib/testutils"
"github.com/syncthing/syncthing/lib/util" "github.com/syncthing/syncthing/lib/util"
@ -2964,7 +2965,9 @@ func TestConnCloseOnRestart(t *testing.T) {
br := &testutils.BlockingRW{} br := &testutils.BlockingRW{}
nw := &testutils.NoopRW{} nw := &testutils.NoopRW{}
m.AddConnection(protocol.NewConnection(device1, br, nw, testutils.NoopCloser{}, m, new(protocolmocks.ConnectionInfo), protocol.CompressionNever, nil, m.keyGen), protocol.Hello{}) ci := &protocolmocks.ConnectionInfo{}
ci.ConnectionIDReturns(rand.String(16))
m.AddConnection(protocol.NewConnection(device1, br, nw, testutils.NoopCloser{}, m, ci, protocol.CompressionNever, nil, m.keyGen), protocol.Hello{})
m.pmut.RLock() m.pmut.RLock()
if len(m.closed) != 1 { if len(m.closed) != 1 {
t.Fatalf("Expected just one conn (len(m.closed) == %v)", len(m.closed)) t.Fatalf("Expected just one conn (len(m.closed) == %v)", len(m.closed))

View File

@ -440,6 +440,8 @@ func (c *rawConnection) readerLoop() {
} }
func (c *rawConnection) dispatcherLoop() (err error) { func (c *rawConnection) dispatcherLoop() (err error) {
l.Infof("dispatcher loop started: %v", err)
defer l.Infof("dispatcher loop stopped: %v", err)
defer close(c.dispatcherLoopStopped) defer close(c.dispatcherLoopStopped)
var msg message var msg message
state := stateInitial state := stateInitial