mirror of
https://github.com/gin-gonic/gin.git
synced 2026-06-12 08:38:16 +08:00
Compare commits
2 Commits
e0ec69e4cd
...
1e4720f1cd
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1e4720f1cd | ||
|
|
a7b757e338 |
12
gin.go
12
gin.go
@ -677,13 +677,17 @@ func (engine *Engine) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||
// If we're using internalContext then we need to pass on errors from the request context
|
||||
if c.useInternalContext() {
|
||||
reqCtx := req.Context()
|
||||
|
||||
// we need to get the cancelCause function now, so that we have the function for this request
|
||||
// because the c is a pointer to a Context that will possibly go back into the pool and be reused
|
||||
c.internalContextMu.RLock()
|
||||
cancelCause := c.internalContextCancelCause
|
||||
c.internalContextMu.RUnlock()
|
||||
|
||||
go func() {
|
||||
<-reqCtx.Done()
|
||||
if err := reqCtx.Err(); err != nil {
|
||||
c.internalContextMu.RLock()
|
||||
defer c.internalContextMu.RUnlock()
|
||||
|
||||
c.internalContextCancelCause(err)
|
||||
cancelCause(err)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user