mirror of
https://github.com/octoleo/syncthing.git
synced 2025-01-03 15:17:25 +00:00
Delete deadlock
This commit is contained in:
parent
8d5aed410f
commit
fff50b5472
@ -138,7 +138,7 @@ func (m *Model) StartRW(del bool, threads int) {
|
||||
|
||||
go m.cleanTempFiles()
|
||||
if del {
|
||||
go m.deleteFiles()
|
||||
go m.deleteLoop()
|
||||
}
|
||||
}
|
||||
|
||||
@ -654,6 +654,8 @@ func (m *Model) recomputeGlobal() {
|
||||
|
||||
// Must be called with the write lock held.
|
||||
func (m *Model) recomputeNeed() {
|
||||
var toDelete []File
|
||||
|
||||
for n, gf := range m.global {
|
||||
if m.fq.Queued(n) {
|
||||
continue
|
||||
@ -677,7 +679,7 @@ func (m *Model) recomputeNeed() {
|
||||
}
|
||||
|
||||
if gf.Flags&protocol.FlagDeleted != 0 {
|
||||
m.dq <- gf
|
||||
toDelete = append(toDelete, gf)
|
||||
} else {
|
||||
local, remote := BlockDiff(lf.Blocks, gf.Blocks)
|
||||
fm := fileMonitor{
|
||||
@ -691,6 +693,13 @@ func (m *Model) recomputeNeed() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
go func() {
|
||||
for _, gf := range toDelete {
|
||||
// The receive side needs the lock, which we are holding
|
||||
m.dq <- gf
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
func (m *Model) WhoHas(name string) []string {
|
||||
@ -713,7 +722,7 @@ func (m *Model) whoHas(name string) []string {
|
||||
return remote
|
||||
}
|
||||
|
||||
func (m *Model) deleteFiles() {
|
||||
func (m *Model) deleteLoop() {
|
||||
for file := range m.dq {
|
||||
if m.trace["file"] {
|
||||
log.Println("FILE: Delete", file.Name)
|
||||
|
Loading…
Reference in New Issue
Block a user