syncthing/lib/protocol
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
..
benchmark_test.go lib/connections, lib/model: Refactor connection close handling (fixes #3466) 2016-08-10 09:37:32 +00:00
bep_extensions.go lib/protocol, lib/model: Implement high precision time stamps (fixes #3305) 2016-08-06 13:05:59 +00:00
bep.pb.go lib/protocol, lib/model: Implement high precision time stamps (fixes #3305) 2016-08-06 13:05:59 +00:00
bep.proto lib/protocol, lib/model: Implement high precision time stamps (fixes #3305) 2016-08-06 13:05:59 +00:00
bufferpool.go lib/protocol, lib/discover, lib/db: Use protocol buffer serialization (fixes #3080) 2016-07-04 10:40:29 +00:00
common_test.go lib/connections, lib/model: Refactor connection close handling (fixes #3466) 2016-08-10 09:37:32 +00:00
compression_test.go Add 'lib/protocol/' from commit 'f91191218b192ace841c878f161832d19c09145a' 2015-09-22 19:34:29 +02:00
compression.go lib/protocol, lib/discover, lib/db: Use protocol buffer serialization (fixes #3080) 2016-07-04 10:40:29 +00:00
conflict_test.go lib/protocol, lib/model: Implement high precision time stamps (fixes #3305) 2016-08-06 13:05:59 +00:00
counting.go Add 'lib/protocol/' from commit 'f91191218b192ace841c878f161832d19c09145a' 2015-09-22 19:34:29 +02:00
debug.go lib/protocol, lib/discover, lib/db: Use protocol buffer serialization (fixes #3080) 2016-07-04 10:40:29 +00:00
deviceid_test.go A couple of protocol tests 2016-01-20 11:37:48 -08:00
deviceid.go lib: Use bytes.Equal instead of bytes.Compare where possible 2016-03-31 15:12:46 +00:00
doc.go Add 'lib/protocol/' from commit 'f91191218b192ace841c878f161832d19c09145a' 2015-09-22 19:34:29 +02:00
errors.go lib/protocol, lib/discover, lib/db: Use protocol buffer serialization (fixes #3080) 2016-07-04 10:40:29 +00:00
hello_test.go lib/protocol: Hello message length is an int16 2016-07-17 21:41:20 +00:00
hello_v0.13_xdr.go lib/protocol: Understand older/newer Hello messages (fixes #3287) 2016-06-09 10:50:14 +00:00
hello_v0.13.go lib/protocol: Understand older/newer Hello messages (fixes #3287) 2016-06-09 10:50:14 +00:00
hello.go lib/protocol: Hello message length is an int16 2016-07-17 21:41:20 +00:00
LICENSE Add 'lib/protocol/' from commit 'f91191218b192ace841c878f161832d19c09145a' 2015-09-22 19:34:29 +02:00
nativemodel_darwin.go lib/protocol, lib/discover, lib/db: Use protocol buffer serialization (fixes #3080) 2016-07-04 10:40:29 +00:00
nativemodel_unix.go lib/model, lib/protocol: Implement temporary indexes (fixes #950) 2016-04-15 10:59:41 +00:00
nativemodel_windows.go cmd/syncthing, lib/...: Correctly handle ignores & invalid file names (fixes #3012, fixes #3457, fixes #3458) 2016-08-05 07:13:52 +00:00
protocol_test.go lib/protocol, lib/model: Implement high precision time stamps (fixes #3305) 2016-08-06 13:05:59 +00:00
protocol.go lib/connections, lib/model: Refactor connection close handling (fixes #3466) 2016-08-10 09:37:32 +00:00
vector_test.go lib/protocol, lib/discover, lib/db: Use protocol buffer serialization (fixes #3080) 2016-07-04 10:40:29 +00:00
vector.go lib/protocol, lib/discover, lib/db: Use protocol buffer serialization (fixes #3080) 2016-07-04 10:40:29 +00:00
wireformat.go lib/protocol, lib/discover, lib/db: Use protocol buffer serialization (fixes #3080) 2016-07-04 10:40:29 +00:00