Make sure CPU profile actually gets written before exiting

This commit is contained in:
Jakob Borg 2015-07-20 15:34:40 +02:00
parent 491452a19d
commit d3387e2a28

View File

@ -672,7 +672,6 @@ func syncthingMain() {
log.Fatal(err) log.Fatal(err)
} }
pprof.StartCPUProfile(f) pprof.StartCPUProfile(f)
defer pprof.StopCPUProfile()
} }
for _, device := range cfg.Devices() { for _, device := range cfg.Devices() {
@ -728,6 +727,11 @@ func syncthingMain() {
mainSvc.Stop() mainSvc.Stop()
l.Okln("Exiting") l.Okln("Exiting")
if cpuProfile {
pprof.StopCPUProfile()
}
os.Exit(code) os.Exit(code)
} }