mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-05-08 22:30:41 +00:00
Merge pull request #307 from vincentbernat/fix/defer-lock
Fix lock handling in cache flusher for API
This commit is contained in:
+17
-15
@@ -32,25 +32,27 @@ func cacheFlusher() {
|
|||||||
for {
|
for {
|
||||||
<-ticker
|
<-ticker
|
||||||
|
|
||||||
// lock everything to eliminate in-progress calls
|
func() {
|
||||||
r := context.CollectionFactory().RemoteRepoCollection()
|
// lock everything to eliminate in-progress calls
|
||||||
r.Lock()
|
r := context.CollectionFactory().RemoteRepoCollection()
|
||||||
defer r.Unlock()
|
r.Lock()
|
||||||
|
defer r.Unlock()
|
||||||
|
|
||||||
l := context.CollectionFactory().LocalRepoCollection()
|
l := context.CollectionFactory().LocalRepoCollection()
|
||||||
l.Lock()
|
l.Lock()
|
||||||
defer l.Unlock()
|
defer l.Unlock()
|
||||||
|
|
||||||
s := context.CollectionFactory().SnapshotCollection()
|
s := context.CollectionFactory().SnapshotCollection()
|
||||||
s.Lock()
|
s.Lock()
|
||||||
defer s.Unlock()
|
defer s.Unlock()
|
||||||
|
|
||||||
p := context.CollectionFactory().PublishedRepoCollection()
|
p := context.CollectionFactory().PublishedRepoCollection()
|
||||||
p.Lock()
|
p.Lock()
|
||||||
defer p.Unlock()
|
defer p.Unlock()
|
||||||
|
|
||||||
// all collections locked, flush them
|
// all collections locked, flush them
|
||||||
context.CollectionFactory().Flush()
|
context.CollectionFactory().Flush()
|
||||||
|
}()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user