File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import (
1111 "net/url"
1212 "os"
1313 "strings"
14+ "sync"
1415
1516 "github.com/rclone/rclone/cmd"
1617 "github.com/rclone/rclone/fs"
@@ -201,14 +202,18 @@ Use --no-auth to disable authentication entirely:
201202 }
202203 }
203204
204- // Wait for either server to exit, then shut both down
205+ // Wait for either server to exit, then shut both down and
206+ // join the second goroutine before returning.
205207 defer systemd .Notify ()()
208+ var wg sync.WaitGroup
206209 done := make (chan struct {}, 2 )
207- go func () { rcServer .Wait (); done <- struct {}{} }()
208- go func () { guiServer .Wait (); done <- struct {}{} }()
210+ wg .Add (2 )
211+ go func () { defer wg .Done (); rcServer .Wait (); done <- struct {}{} }()
212+ go func () { defer wg .Done (); guiServer .Wait (); done <- struct {}{} }()
209213 <- done
210214 _ = rcServer .Shutdown ()
211215 _ = guiServer .Shutdown ()
216+ wg .Wait ()
212217 return nil
213218 },
214219}
You can’t perform that action at this time.
0 commit comments