mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-09 23:00:58 +00:00
Send index in chunks of 1000 to avoid lengthy blocking
This commit is contained in:
parent
a2a2e1d466
commit
fd56123acf
15
model.go
15
model.go
@ -468,13 +468,16 @@ func (m *Model) AddNode(node *protocol.Connection) {
|
|||||||
idx := m.protocolIndex()
|
idx := m.protocolIndex()
|
||||||
m.RUnlock()
|
m.RUnlock()
|
||||||
|
|
||||||
if opts.Debug.TraceNet {
|
for i := 0; i < len(idx); i += 1000 {
|
||||||
debugf("NET IDX(out/add): %s: %d files", node.ID, len(idx))
|
s := i + 1000
|
||||||
|
if s > len(idx) {
|
||||||
|
s = len(idx)
|
||||||
|
}
|
||||||
|
if opts.Debug.TraceNet {
|
||||||
|
debugf("NET IDX(out/add): %s: %d:%d", node.ID, i, s)
|
||||||
|
}
|
||||||
|
node.Index(idx[i:s])
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sending the index might take a while if we have many files and a slow
|
|
||||||
// uplink. Return from AddNode in the meantime.
|
|
||||||
go node.Index(idx)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func fileFromFileInfo(f protocol.FileInfo) File {
|
func fileFromFileInfo(f protocol.FileInfo) File {
|
||||||
|
Loading…
Reference in New Issue
Block a user