Skip to content
Snippets Groups Projects
Commit 1261aade authored by Mike Chiu's avatar Mike Chiu Committed by Alex Ellis
Browse files

Fix fwatchdog timer memory leak issue


Use timer.AfterFunc to make sure goroutine could be gc.

Signed-off-by: default avatarMike Chiu <mike.chiu@pentium.network>
parent cfac88b0
No related branches found
No related tags found
No related merge requests found
......@@ -109,10 +109,7 @@ func pipeRequest(config *WatchdogConfig, w http.ResponseWriter, r *http.Request,
var timer *time.Timer
if config.execTimeout > 0*time.Second {
timer = time.NewTimer(config.execTimeout)
go func() {
<-timer.C
timer = time.AfterFunc(config.execTimeout, func() {
log.Printf("Killing process: %s\n", config.faasProcess)
if targetCmd != nil && targetCmd.Process != nil {
ri.headerWritten = true
......@@ -125,7 +122,7 @@ func pipeRequest(config *WatchdogConfig, w http.ResponseWriter, r *http.Request,
log.Printf("Killed process: %s - error %s\n", config.faasProcess, val.Error())
}
}
}()
})
}
// Write to pipe in separate go-routine to prevent blocking
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment