MCPcopy
hub / github.com/gofiber/fiber / ReleaseCtx

Method ReleaseCtx

ctx_interface.go:124–137  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

122// requestHandler and ErrorHandler) still touch the context; the timeout
123// middleware intentionally leaves abandoned contexts unreleased to avoid races.
124func (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
139func (app *App) releaseDefaultCtx(c *DefaultCtx) {
140 if c.IsAbandoned() {

Calls 4

IsAbandonedMethod · 0.65
signalReleasedMethod · 0.65
releaseMethod · 0.65
PutMethod · 0.65