MCPcopy Index your code
hub / github.com/php/frankenphp / threadDebugState

Function threadDebugState

debugstate.go:48–96  ·  view source on GitHub ↗

threadDebugState creates a small jsonable status message for debugging purposes

(thread *phpThread)

Source from the content-addressed store, hash-verified

46
47// threadDebugState creates a small jsonable status message for debugging purposes
48func threadDebugState(thread *phpThread) ThreadDebugState {
49 isBusy := !thread.state.IsInWaitingState()
50
51 s := ThreadDebugState{
52 Index: thread.threadIndex,
53 Name: thread.name(),
54 State: thread.state.Name(),
55 IsWaiting: thread.state.IsInWaitingState(),
56 IsBusy: isBusy,
57 WaitingSinceMilliseconds: thread.state.WaitTime(),
58 }
59
60 s.RequestCount = thread.requestCount.Load()
61 s.MemoryUsage = int64(C.frankenphp_get_thread_memory_usage(C.uintptr_t(thread.threadIndex)))
62
63 if !isBusy {
64 return s
65 }
66
67 thread.handlerMu.RLock()
68 handler := thread.handler
69 thread.handlerMu.RUnlock()
70
71 if handler == nil {
72 return s
73 }
74
75 thread.contextMu.RLock()
76 defer thread.contextMu.RUnlock()
77
78 fc := handler.frankenPHPContext()
79 if fc == nil || fc.request == nil || fc.responseWriter == nil {
80 return s
81 }
82
83 if fc.originalRequest == nil {
84 s.CurrentURI = fc.requestURI
85 s.CurrentMethod = fc.request.Method
86 } else {
87 s.CurrentURI = fc.originalRequest.URL.RequestURI()
88 s.CurrentMethod = fc.originalRequest.Method
89 }
90
91 if !fc.startedAt.IsZero() {
92 s.RequestStartedAt = fc.startedAt.UnixMilli()
93 }
94
95 return s
96}

Callers 1

DebugStateFunction · 0.85

Calls 5

IsInWaitingStateMethod · 0.80
NameMethod · 0.80
WaitTimeMethod · 0.80
nameMethod · 0.65
frankenPHPContextMethod · 0.65

Tested by

no test coverage detected