()
| 86 | func (handler *regularThread) drain() {} |
| 87 | |
| 88 | func (handler *regularThread) waitForRequest() string { |
| 89 | // max_requests reached: restart the thread to clean up all ZTS state |
| 90 | if maxRequestsPerThread > 0 && handler.requestCount >= maxRequestsPerThread { |
| 91 | if globalLogger.Enabled(globalCtx, slog.LevelDebug) { |
| 92 | globalLogger.LogAttrs(globalCtx, slog.LevelDebug, "max requests reached, restarting thread", |
| 93 | slog.Int("thread", handler.thread.threadIndex), |
| 94 | slog.Int("max_requests", maxRequestsPerThread), |
| 95 | ) |
| 96 | } |
| 97 | |
| 98 | if handler.thread.reboot() { |
| 99 | return "" |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | handler.state.MarkAsWaiting(true) |
| 104 | |
| 105 | var ch contextHolder |
| 106 | |
| 107 | select { |
| 108 | case <-handler.thread.drainChan: |
| 109 | // go back to beforeScriptExecution |
| 110 | return handler.beforeScriptExecution() |
| 111 | case ch = <-regularRequestChan: |
| 112 | case ch = <-handler.thread.requestChan: |
| 113 | } |
| 114 | |
| 115 | handler.requestCount++ |
| 116 | handler.thread.contextMu.Lock() |
| 117 | handler.ctx = ch.ctx |
| 118 | handler.contextHolder.frankenPHPContext = ch.frankenPHPContext |
| 119 | handler.thread.contextMu.Unlock() |
| 120 | handler.state.MarkAsWaiting(false) |
| 121 | |
| 122 | // set the scriptFilename that should be executed |
| 123 | return handler.contextHolder.frankenPHPContext.scriptFilename |
| 124 | } |
| 125 | |
| 126 | func (handler *regularThread) afterRequest() { |
| 127 | handler.contextHolder.frankenPHPContext.closeContext() |
no test coverage detected