Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions phpthread.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ type threadHandler interface {
afterScriptExecution(exitStatus int)
context() context.Context
frankenPHPContext() *frankenPHPContext
// drain is a hook called by drainWorkerThreads right before drainChan is
// closed. Handlers that need to wake up a thread parked in a blocking C
// call (e.g. by closing a stop pipe) plug their signal in here. All
// current handlers are no-ops; this is the seam later handler types use
// without having to modify drainWorkerThreads.
drain()
}

func newPHPThread(threadIndex int) *phpThread {
Expand Down
2 changes: 2 additions & 0 deletions threadinactive.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,5 @@ func (handler *inactiveThread) context() context.Context {
func (handler *inactiveThread) name() string {
return "Inactive PHP Thread"
}

func (handler *inactiveThread) drain() {}
2 changes: 2 additions & 0 deletions threadregular.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ func (handler *regularThread) name() string {
return "Regular PHP Thread"
}

func (handler *regularThread) drain() {}

func (handler *regularThread) waitForRequest() string {
// max_requests reached: restart the thread to clean up all ZTS state
if maxRequestsPerThread > 0 && handler.requestCount >= maxRequestsPerThread {
Expand Down
2 changes: 2 additions & 0 deletions threadtasks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ func (handler *taskThread) name() string {
return "Task PHP Thread"
}

func (handler *taskThread) drain() {}

func (handler *taskThread) waitForTasks() {
for {
select {
Expand Down
2 changes: 2 additions & 0 deletions threadworker.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ func (handler *workerThread) name() string {
return "Worker PHP Thread - " + handler.worker.fileName
}

func (handler *workerThread) drain() {}

func setupWorkerScript(handler *workerThread, worker *worker) {
metrics.StartWorker(worker.name)

Expand Down
1 change: 1 addition & 0 deletions worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ func drainWorkerThreads() []*phpThread {
continue
}

thread.handler.drain()
close(thread.drainChan)
drainedThreads = append(drainedThreads, thread)

Expand Down
Loading