fix: use the global logger during classes preloading (#1994)

* fix: use the global logger during classes preloading

* better fix

* fix comparision

* Update frankenphp.go
This commit is contained in:
Kévin Dunglas
2025-11-19 14:18:29 +01:00
committed by GitHub
parent f224f8e391
commit 10cf2c4a2e
3 changed files with 12 additions and 6 deletions

View File

@@ -652,12 +652,11 @@ func go_read_cookies(threadIndex C.uintptr_t) *C.char {
//export go_log
func go_log(threadIndex C.uintptr_t, message *C.char, level C.int) {
ctx := phpThreads[threadIndex].context()
m := C.GoString(message)
var le syslogLevel
if level < C.int(syslogLevelEmerg) || level > C.int(syslogLevelDebug) {
le = syslogLevelInfo
} else {
m := C.GoString(message)
le := syslogLevelInfo
if level >= C.int(syslogLevelEmerg) && level <= C.int(syslogLevelDebug) {
le = syslogLevel(level)
}

View File

@@ -82,10 +82,12 @@ func (thread *phpThread) shutdown() {
func (thread *phpThread) setHandler(handler threadHandler) {
thread.handlerMu.Lock()
defer thread.handlerMu.Unlock()
if !thread.state.requestSafeStateChange(stateTransitionRequested) {
// no state change allowed == shutdown or done
return
}
close(thread.drainChan)
thread.state.waitFor(stateTransitionInProgress)
thread.handler = handler
@@ -108,6 +110,11 @@ func (thread *phpThread) frankenPHPContext() *frankenPHPContext {
}
func (thread *phpThread) context() context.Context {
if thread.handler == nil {
// handler can be nil when using opcache.preload
return globalCtx
}
return thread.handler.context()
}

View File

@@ -48,7 +48,7 @@ func (handler *inactiveThread) frankenPHPContext() *frankenPHPContext {
}
func (handler *inactiveThread) context() context.Context {
return nil
return globalCtx
}
func (handler *inactiveThread) name() string {