go_frankenphp_finish_worker_request is called at the end of every php request served. export go_frankenphp_finish_worker_request
(threadIndex C.uintptr_t, retval *C.zval)
| 309 | // |
| 310 | //export go_frankenphp_finish_worker_request |
| 311 | func go_frankenphp_finish_worker_request(threadIndex C.uintptr_t, retval *C.zval) { |
| 312 | thread := phpThreads[threadIndex] |
| 313 | ctx := thread.context() |
| 314 | fc := ctx.Value(contextKey).(*frankenPHPContext) |
| 315 | |
| 316 | if retval != nil { |
| 317 | r, err := GoValue[any](unsafe.Pointer(retval)) |
| 318 | if err != nil && globalLogger.Enabled(ctx, slog.LevelError) { |
| 319 | globalLogger.LogAttrs(ctx, slog.LevelError, "cannot convert return value", slog.Any("error", err), slog.Int("thread", thread.threadIndex)) |
| 320 | } |
| 321 | |
| 322 | fc.handlerReturn = r |
| 323 | } |
| 324 | |
| 325 | thread.requestCount.Add(1) |
| 326 | |
| 327 | fc.closeContext() |
| 328 | thread.contextMu.Lock() |
| 329 | thread.handler.(*workerThread).workerFrankenPHPContext = nil |
| 330 | thread.handler.(*workerThread).workerContext = nil |
| 331 | thread.contextMu.Unlock() |
| 332 | |
| 333 | if globalLogger.Enabled(ctx, slog.LevelDebug) { |
| 334 | if fc.request == nil { |
| 335 | fc.logger.LogAttrs(ctx, slog.LevelDebug, "request handling finished", slog.String("worker", fc.worker.name), slog.Int("thread", thread.threadIndex)) |
| 336 | } else { |
| 337 | fc.logger.LogAttrs(ctx, slog.LevelDebug, "request handling finished", slog.String("worker", fc.worker.name), slog.Int("thread", thread.threadIndex), slog.String("url", fc.request.RequestURI)) |
| 338 | } |
| 339 | } |
| 340 | } |
| 341 | |
| 342 | // when frankenphp_finish_request() is directly called from PHP |
| 343 | // |
nothing calls this directly
no test coverage detected