ReleaseCtx releases the ctx back into the pool. If the context was abandoned (e.g., by timeout middleware), this is a no-op. Call ForceRelease only when you can guarantee no goroutines (including the requestHandler and ErrorHandler) still touch the context; the timeout middleware intentionally leave
(c CustomCtx)
| 122 | // requestHandler and ErrorHandler) still touch the context; the timeout |
| 123 | // middleware intentionally leaves abandoned contexts unreleased to avoid races. |
| 124 | func (app *App) ReleaseCtx(c CustomCtx) { |
| 125 | if c.IsAbandoned() { |
| 126 | // If reclamation was armed (see ScheduleReclaim), signal that the request |
| 127 | // handler is done so the reclaimer can return the ctx to the pool. The ctx |
| 128 | // is still not pooled here; the reclaimer does that once the handler also |
| 129 | // finishes. Otherwise (e.g. SSE) leave it unreleased as before. |
| 130 | if dc, ok := c.(*DefaultCtx); ok { |
| 131 | dc.signalReleased() |
| 132 | } |
| 133 | return |
| 134 | } |
| 135 | c.release() |
| 136 | app.pool.Put(c) |
| 137 | } |
| 138 | |
| 139 | func (app *App) releaseDefaultCtx(c *DefaultCtx) { |
| 140 | if c.IsAbandoned() { |