Lock snapshot collection before sorting

This commit is contained in:
Sylvain Baubeau
2015-01-06 18:01:11 +01:00
parent 6bc7048166
commit 6a1a871dda
+6 -1
View File
@@ -13,7 +13,12 @@ func apiSnapshotsList(c *gin.Context) {
SortMethodString := c.Request.URL.Query().Get("sort")
collection := context.CollectionFactory().SnapshotCollection()
collection.Sort(SortMethodString)
collection.RLock()
defer collection.RUnlock()
if SortMethodString != "" {
collection.Sort(SortMethodString)
}
result := []*deb.Snapshot{}
collection.ForEach(func(snapshot *deb.Snapshot) error {