Skip to content

Commit

Permalink
Wait for cache cleanup goroutine to finish
Browse files Browse the repository at this point in the history
  • Loading branch information
haoming29 committed Nov 28, 2023
1 parent ce4ba29 commit d2e419a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions cmd/cache_serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,11 @@ func serveCache( /*cmd*/ *cobra.Command /*args*/, []string) error {
shutdownCtx, shutdownCancel := context.WithCancel(context.Background())
var wg sync.WaitGroup

defer config.CleanupTempResources()
defer shutdownCancel()
defer func() {
shutdownCancel()
wg.Wait()
config.CleanupTempResources()
}()

err := config.DiscoverFederation()
if err != nil {
Expand Down
7 changes: 5 additions & 2 deletions cmd/origin_serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,11 @@ func serveOrigin( /*cmd*/ *cobra.Command /*args*/, []string) error {
shutdownCtx, shutdownCancel := context.WithCancel(context.Background())
var wg sync.WaitGroup

defer config.CleanupTempResources()
defer shutdownCancel()
defer func() {
shutdownCancel()
wg.Wait()
config.CleanupTempResources()
}()

wg.Add(1)
err := xrootd.SetUpMonitoring(shutdownCtx, &wg)
Expand Down

0 comments on commit d2e419a

Please # to comment.