syncthing/lib/model
Jakob Borg e52be3d83e lib/connections, lib/model: Refactor connection close handling (fixes #3466)
So there were some issues here. The main problem was that
model.Close(deviceID) was overloaded to mean "the connection was closed
by the protocol layer" and "i want to close this connection". That meant
it could get called twice - once *to* close the connection and then once
more when the connection *was* closed.

After this refactor there is instead a Closed(conn) method that is the
callback. I didn't need to change the parameter in the end, but I think
it's clearer what it means when it takes the connection that was closed
instead of a device ID. To close a connection, the new close(deviceID)
method is used instead, which only closes the underlying connection and
leaves the cleanup to the Closed() callback.

I also changed how we do connection switching. Instead of the connection
service calling close and then adding the connection, it just adds the
new connection. The model knows that it already has a connection and
makes sure to close and clean out that one before adding the new
connection.

To make sure to sequence this properly I added a new map of channels
that get created on connection add and closed by Closed(), so that
AddConnection() can do the close and wait for the cleanup to happen
before proceeding.

GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3490
2016-08-10 09:37:32 +00:00
..
testdata mv internal lib 2015-08-09 09:35:26 +02:00
.gitignore mv internal lib 2015-08-09 09:35:26 +02:00
debug.go Implement facility based logger, debugging via REST API 2015-10-03 18:09:53 +02:00
deviceactivity_test.go lib/model, lib/protocol: Implement temporary indexes (fixes #950) 2016-04-15 10:59:41 +00:00
deviceactivity.go lib/model, lib/protocol: Implement temporary indexes (fixes #950) 2016-04-15 10:59:41 +00:00
devicedownloadstate_test.go lib/model: Test should pass go vet inspections 2016-04-15 11:41:18 +00:00
devicedownloadstate.go lib/model: Don't deadlock when returning temp index block counts 2016-05-26 09:16:08 +00:00
doc.go mv internal lib 2015-08-09 09:35:26 +02:00
folder.go lib/model: Refactor encapsulation of the folder scanning 2016-06-29 06:37:34 +00:00
folderscanner.go lib/model: Refactor encapsulation of the folder scanning 2016-06-29 06:37:34 +00:00
folderstate.go lib/model: Refactor encapsulation of the folder scanning 2016-06-29 06:37:34 +00:00
model_test.go lib/connections, lib/model: Refactor connection close handling (fixes #3466) 2016-08-10 09:37:32 +00:00
model.go lib/connections, lib/model: Refactor connection close handling (fixes #3466) 2016-08-10 09:37:32 +00:00
progressemitter_test.go lib/protocol, lib/discover, lib/db: Use protocol buffer serialization (fixes #3080) 2016-07-04 10:40:29 +00:00
progressemitter.go lib/protocol, lib/discover, lib/db: Use protocol buffer serialization (fixes #3080) 2016-07-04 10:40:29 +00:00
queue_test.go lib/protocol, lib/model: Implement high precision time stamps (fixes #3305) 2016-08-06 13:05:59 +00:00
queue.go lib/protocol, lib/model: Implement high precision time stamps (fixes #3305) 2016-08-06 13:05:59 +00:00
rofolder.go lib/db, lib/fs, lib/model: Introduce fs.MtimeFS, remove VirtualMtimeRepo 2016-08-05 17:45:45 +00:00
rwfolder_test.go lib/protocol, lib/model: Implement high precision time stamps (fixes #3305) 2016-08-06 13:05:59 +00:00
rwfolder.go lib/protocol, lib/model: Implement high precision time stamps (fixes #3305) 2016-08-06 13:05:59 +00:00
sentdownloadstate.go lib/model: Track puller creation times (fixes #3145) 2016-05-22 10:16:09 +00:00
sharedpullerstate_test.go cmd, lib: Fix ineffectual assignments (ineffasign) and comment spelling 2016-07-15 14:23:20 +00:00
sharedpullerstate.go lib/model: Stricter temporary file permissions 2016-07-25 10:18:05 +00:00
sorter_test.go lib/protocol, lib/model: Implement high precision time stamps (fixes #3305) 2016-08-06 13:05:59 +00:00
sorter.go all: Rename LocalVersion to Sequence (fixes #3461) 2016-07-29 19:54:24 +00:00
tempname_test.go mv internal lib 2015-08-09 09:35:26 +02:00
tempname.go lib/model: Decrease max temp filename length (fixes #3338, fixes #3355) 2016-06-27 11:47:40 +00:00
util.go mv internal lib 2015-08-09 09:35:26 +02:00