Просмотр исходного кода

Prevent possible reordering of Index/IndexUpdate on send (ref #344)

Jakob Borg 11 лет назад
Родитель
Сommit
66d4e9e5d7
1 измененных файлов с 4 добавлено и 2 удалено
  1. 4 2
      protocol/protocol.go

+ 4 - 2
protocol/protocol.go

@@ -165,9 +165,11 @@ func (c *rawConnection) Index(repo string, idx []FileInfo) {
 		}
 		idx = diff
 	}
-	c.imut.Unlock()
 
-	c.send(header{0, -1, msgType}, IndexMessage{repo, idx})
+	if len(idx) > 0 {
+		c.send(header{0, -1, msgType}, IndexMessage{repo, idx})
+	}
+	c.imut.Unlock()
 }
 
 // Request returns the bytes for the specified block after fetching them from the connected peer.