Skip to content

Commit bc6a036

Browse files
handle nil thread handler
1 parent f4211e1 commit bc6a036

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

debugstate.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ func threadDebugState(thread *phpThread) ThreadDebugState {
6767
thread.handlerMu.RLock()
6868
defer thread.handlerMu.RUnlock()
6969

70+
if thread.handler == nil {
71+
return s
72+
}
73+
7074
fc := thread.handler.frankenPHPContext()
7175
if fc == nil || fc.request == nil || fc.responseWriter == nil {
7276
return s

phpthread.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,13 @@ func (thread *phpThread) context() context.Context {
127127

128128
func (thread *phpThread) name() string {
129129
thread.handlerMu.RLock()
130-
name := thread.handler.name()
131-
thread.handlerMu.RUnlock()
130+
defer thread.handlerMu.RUnlock()
132131

133-
return name
132+
if thread.handler == nil {
133+
return "unknown"
134+
}
135+
136+
return thread.handler.name()
134137
}
135138

136139
// Pin a string that is not null-terminated

0 commit comments

Comments
 (0)