diff options
author | Jakob Borg <jakob@kastelo.net> | 2023-09-06 12:52:01 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-06 12:52:01 +0200 |
commit | c6334e61aa56575db6b274d45d55f7ada4dcd0fe (patch) | |
tree | 1267b2b1e67c09d80843b45b88049892dbedef7f /cmd | |
parent | 38bbdebffa74df9e5937749a3780d39b24adc331 (diff) | |
download | syncthing-c6334e61aa56575db6b274d45d55f7ada4dcd0fe.tar.gz syncthing-c6334e61aa56575db6b274d45d55f7ada4dcd0fe.zip |
all: Support multiple device connections (fixes #141) (#8918)
This adds the ability to have multiple concurrent connections to a single device. This is primarily useful when the network has multiple physical links for aggregated bandwidth. A single connection will never see a higher rate than a single link can give, but multiple connections are load-balanced over multiple links.
It is also incidentally useful for older multi-core CPUs, where bandwidth could be limited by the TLS performance of a single CPU core -- using multiple connections achieves concurrency in the required crypto calculations...
Co-authored-by: Simon Frei <freisim93@gmail.com>
Co-authored-by: tomasz1986 <twilczynski@naver.com>
Co-authored-by: bt90 <btom1990@googlemail.com>
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/stdiscosrv/database.go | 10 | ||||
-rw-r--r-- | cmd/stdiscosrv/database_test.go | 2 |
2 files changed, 3 insertions, 9 deletions
diff --git a/cmd/stdiscosrv/database.go b/cmd/stdiscosrv/database.go index ce151da3c..92ed45db6 100644 --- a/cmd/stdiscosrv/database.go +++ b/cmd/stdiscosrv/database.go @@ -15,6 +15,7 @@ import ( "sort" "time" + "github.com/syncthing/syncthing/lib/sliceutil" "github.com/syndtr/goleveldb/leveldb" "github.com/syndtr/goleveldb/leveldb/storage" "github.com/syndtr/goleveldb/leveldb/util" @@ -352,14 +353,7 @@ func expire(addrs []DatabaseAddress, now int64) []DatabaseAddress { i := 0 for i < len(addrs) { if addrs[i].Expires < now { - // This item is expired. Replace it with the last in the list - // (noop if we are at the last item). - addrs[i] = addrs[len(addrs)-1] - // Wipe the last item of the list to release references to - // strings and stuff. - addrs[len(addrs)-1] = DatabaseAddress{} - // Shorten the slice. - addrs = addrs[:len(addrs)-1] + addrs = sliceutil.RemoveAndZero(addrs, i) continue } i++ diff --git a/cmd/stdiscosrv/database_test.go b/cmd/stdiscosrv/database_test.go index 2596b6b17..14b15059d 100644 --- a/cmd/stdiscosrv/database_test.go +++ b/cmd/stdiscosrv/database_test.go @@ -185,7 +185,7 @@ func TestFilter(t *testing.T) { }, { a: []DatabaseAddress{{Address: "a", Expires: 5}, {Address: "b", Expires: 15}, {Address: "c", Expires: 5}, {Address: "d", Expires: 15}, {Address: "e", Expires: 5}}, - b: []DatabaseAddress{{Address: "d", Expires: 15}, {Address: "b", Expires: 15}}, // gets reordered + b: []DatabaseAddress{{Address: "b", Expires: 15}, {Address: "d", Expires: 15}}, }, } |