Skip to content

Commit 4b18059

Browse files
committed
Formatting.
1 parent 5095342 commit 4b18059

File tree

5 files changed

+24
-24
lines changed

5 files changed

+24
-24
lines changed

phpmainthread_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func TestTransitionThreadsWhileDoingRequests(t *testing.T) {
103103
case 2:
104104
convertToWorkerThread(phpThreads[i], workers[worker2Path])
105105
case 3:
106-
convertToInactiveThread(phpThreads[i])
106+
convertToInactiveThread(phpThreads[i])
107107
}
108108
time.Sleep(time.Millisecond)
109109
if !isRunning.Load() {

phpthread.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@ func newPHPThread(threadIndex int) *phpThread {
4040
}
4141
}
4242

43-
func (thread *phpThread) getActiveRequest() *http.Request {
44-
return thread.handler.getActiveRequest()
45-
}
46-
4743
// change the thread handler safely
4844
func (thread *phpThread) setHandler(handler threadHandler) {
4945
thread.mu.Lock()
@@ -59,6 +55,10 @@ func (thread *phpThread) setHandler(handler threadHandler) {
5955
thread.state.set(stateTransitionComplete)
6056
}
6157

58+
func (thread *phpThread) getActiveRequest() *http.Request {
59+
return thread.handler.getActiveRequest()
60+
}
61+
6262
// Pin a string that is not null-terminated
6363
// PHP's zend_string may contain null-bytes
6464
func (thread *phpThread) pinString(s string) *C.char {

state.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ func (ts *threadState) compareAndSwap(compareTo stateID, swapTo stateID) bool {
6161
return false
6262
}
6363

64+
func (ts *threadState) name() string {
65+
// TODO: return the actual name for logging/metrics
66+
return "state:" + strconv.Itoa(int(ts.get()))
67+
}
68+
6469
func (ts *threadState) get() stateID {
6570
ts.mu.RLock()
6671
defer ts.mu.RUnlock()
@@ -88,11 +93,6 @@ func (h *threadState) set(nextState stateID) {
8893
h.subscribers = newSubscribers
8994
}
9095

91-
func (ts *threadState) name() string {
92-
// TODO: return the actual name for logging/metrics
93-
return "state:" + strconv.Itoa(int(ts.get()))
94-
}
95-
9696
// block until the thread reaches a certain state
9797
func (h *threadState) waitFor(states ...stateID) {
9898
h.mu.Lock()

thread-inactive.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ func convertToInactiveThread(thread *phpThread) {
1818
thread.setHandler(&inactiveThread{thread: thread})
1919
}
2020

21-
func (thread *inactiveThread) getActiveRequest() *http.Request {
22-
panic("inactive threads have no requests")
23-
}
24-
2521
func (handler *inactiveThread) beforeScriptExecution() string {
2622
thread := handler.thread
2723

@@ -47,3 +43,7 @@ func (handler *inactiveThread) beforeScriptExecution() string {
4743
func (thread *inactiveThread) afterScriptExecution(exitStatus int) {
4844
panic("inactive threads should not execute scripts")
4945
}
46+
47+
func (thread *inactiveThread) getActiveRequest() *http.Request {
48+
panic("inactive threads have no requests")
49+
}

thread-worker.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,6 @@ func convertToWorkerThread(thread *phpThread, worker *worker) {
4141
}
4242
}
4343

44-
func (handler *workerThread) getActiveRequest() *http.Request {
45-
if handler.workerRequest != nil {
46-
return handler.workerRequest
47-
}
48-
49-
return handler.fakeRequest
50-
}
51-
5244
// return the name of the script or an empty string if no script should be executed
5345
func (handler *workerThread) beforeScriptExecution() string {
5446
switch handler.state.get() {
@@ -68,7 +60,7 @@ func (handler *workerThread) beforeScriptExecution() string {
6860
handler.state.waitFor(stateReady, stateShuttingDown)
6961
return handler.beforeScriptExecution()
7062
case stateReady, stateTransitionComplete:
71-
setUpWorkerScript(handler, handler.worker)
63+
setupWorkerScript(handler, handler.worker)
7264
return handler.worker.fileName
7365
}
7466
panic("unexpected state: " + handler.state.name())
@@ -78,7 +70,15 @@ func (handler *workerThread) afterScriptExecution(exitStatus int) {
7870
tearDownWorkerScript(handler, exitStatus)
7971
}
8072

81-
func setUpWorkerScript(handler *workerThread, worker *worker) {
73+
func (handler *workerThread) getActiveRequest() *http.Request {
74+
if handler.workerRequest != nil {
75+
return handler.workerRequest
76+
}
77+
78+
return handler.fakeRequest
79+
}
80+
81+
func setupWorkerScript(handler *workerThread, worker *worker) {
8282
handler.backoff.wait()
8383
metrics.StartWorker(worker.fileName)
8484

0 commit comments

Comments
 (0)