mirror of
https://github.com/dunglas/frankenphp.git
synced 2025-12-24 13:38:11 +08:00
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:
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ func (handler *inactiveThread) frankenPHPContext() *frankenPHPContext {
|
||||
}
|
||||
|
||||
func (handler *inactiveThread) context() context.Context {
|
||||
return nil
|
||||
return globalCtx
|
||||
}
|
||||
|
||||
func (handler *inactiveThread) name() string {
|
||||
|
||||
Reference in New Issue
Block a user