mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
fn: fixup possible go-routine leak (#1265)
This commit is contained in:
@@ -784,10 +784,17 @@ func (s *hotSlot) dispatch(ctx context.Context, call *call) chan error {
|
|||||||
}
|
}
|
||||||
common.Logger(ctx).WithField("resp", resp).Debug("Got resp from UDS socket")
|
common.Logger(ctx).WithField("resp", resp).Debug("Got resp from UDS socket")
|
||||||
|
|
||||||
|
// if ctx is canceled/timedout, then we close the body to unlock writeResp() below
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
ioErrChan := make(chan error, 1)
|
||||||
|
go func() {
|
||||||
|
ioErrChan <- writeResp(s.cfg.MaxResponseSize, resp, call.w)
|
||||||
|
}()
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case errApp <- writeResp(s.cfg.MaxResponseSize, resp, call.w):
|
case ioErr := <-ioErrChan:
|
||||||
|
errApp <- ioErr
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
errApp <- ctx.Err()
|
errApp <- ctx.Err()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user