syncthing/lib
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
..
auto build: Generate gui.files.go on the fly, remove from repo 2016-03-28 10:03:13 +00:00
beacon Remove unused struct field 2015-10-27 09:55:05 +01:00
config lib/model, lib/config: Support "live" device removal, folder unsharing and folder configuration changes 2016-08-07 16:21:59 +00:00
connections lib/connections, lib/model: Refactor connection close handling (fixes #3466) 2016-08-10 09:37:32 +00:00
db lib/model, lib/config: Support "live" device removal, folder unsharing and folder configuration changes 2016-08-07 16:21:59 +00:00
dialer build, lib: Correct total test coverage calculation 2016-08-08 16:29:32 +00:00
discover script, lib/discover: Fixup copyright checks 2016-07-04 14:53:11 +02:00
events lib/events: Hack to make test coverage stable from run to run 2016-08-08 18:09:40 +00:00
fs lib/protocol, lib/model: Implement high precision time stamps (fixes #3305) 2016-08-06 13:05:59 +00:00
ignore vendor: Update github.com/gobwas/glob (fixes #3174) 2016-05-28 04:43:54 +00:00
logger cmd/syncthing: Extract interfaces for things the API depends on 2016-03-21 19:36:08 +00:00
model lib/connections, lib/model: Refactor connection close handling (fixes #3466) 2016-08-10 09:37:32 +00:00
nat lib/nat: Avoid concurrent reset of NAT timer (fixes #3337) 2016-06-26 10:17:12 +00:00
osutil lib/osutil: Return "/" as filesystem root on non-windows (fixes #3321) 2016-06-20 20:25:00 +00:00
pmp build, lib: Correct total test coverage calculation 2016-08-08 16:29:32 +00:00
protocol lib/connections, lib/model: Refactor connection close handling (fixes #3466) 2016-08-10 09:37:32 +00:00
rand lib/rand: Break out random functions into separate package 2016-05-26 07:02:56 +00:00
rc all: Rename LocalVersion to Sequence (fixes #3461) 2016-07-29 19:54:24 +00:00
relay build, lib: Correct total test coverage calculation 2016-08-08 16:29:32 +00:00
scanner lib/protocol, lib/model: Implement high precision time stamps (fixes #3305) 2016-08-06 13:05:59 +00:00
signature The PublicKey() method is an addition in Go 1.4 2015-10-27 16:03:14 +01:00
stats build, lib: Correct total test coverage calculation 2016-08-08 16:29:32 +00:00
symlinks build, lib: Correct total test coverage calculation 2016-08-08 16:29:32 +00:00
sync lib/sync: Skip the timing tests if the host timer is flaky 2016-03-27 10:41:38 +00:00
tlsutil build, lib: Correct total test coverage calculation 2016-08-08 16:29:32 +00:00
upgrade lib/upgrade: Remove TestGithubRelease (fixes #3362) 2016-06-29 19:06:09 +00:00
upnp lib: simplify code 2016-05-18 22:47:11 +00:00
util lib/rand: Break out random functions into separate package 2016-05-26 07:02:56 +00:00
versioner lib/versioner: Hack to make test coverage stable from run to run 2016-08-08 18:27:55 +00:00