mirror of
https://github.com/openfaas/faas.git
synced 2025-06-10 01:06:47 +00:00
Fix fwatchdog timer memory leak issue
Use timer.AfterFunc to make sure goroutine could be gc. Signed-off-by: Mike Chiu <mike.chiu@pentium.network>
This commit is contained in:
parent
cfac88b001
commit
1261aadebe
@ -109,10 +109,7 @@ func pipeRequest(config *WatchdogConfig, w http.ResponseWriter, r *http.Request,
|
|||||||
var timer *time.Timer
|
var timer *time.Timer
|
||||||
|
|
||||||
if config.execTimeout > 0*time.Second {
|
if config.execTimeout > 0*time.Second {
|
||||||
timer = time.NewTimer(config.execTimeout)
|
timer = time.AfterFunc(config.execTimeout, func() {
|
||||||
|
|
||||||
go func() {
|
|
||||||
<-timer.C
|
|
||||||
log.Printf("Killing process: %s\n", config.faasProcess)
|
log.Printf("Killing process: %s\n", config.faasProcess)
|
||||||
if targetCmd != nil && targetCmd.Process != nil {
|
if targetCmd != nil && targetCmd.Process != nil {
|
||||||
ri.headerWritten = true
|
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())
|
log.Printf("Killed process: %s - error %s\n", config.faasProcess, val.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write to pipe in separate go-routine to prevent blocking
|
// Write to pipe in separate go-routine to prevent blocking
|
||||||
|
Loading…
x
Reference in New Issue
Block a user