File tree Expand file tree Collapse file tree 2 files changed +11
-9
lines changed
Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -79,6 +79,16 @@ func (thread *phpThread) shutdown() {
7979 }
8080}
8181
82+ // restart the underlying PHP thread
83+ func (thread * phpThread ) restart () {
84+ if ! thread .state .requestSafeStateChange (stateRestarting ) {
85+ return
86+ }
87+ close (thread .drainChan )
88+ thread .state .waitFor (stateYielding )
89+ thread .drainChan = make (chan struct {})
90+ }
91+
8292// change the thread handler safely
8393// must be called from outside the PHP thread
8494func (thread * phpThread ) setHandler (handler threadHandler ) {
Original file line number Diff line number Diff line change @@ -148,16 +148,8 @@ func drainWorkerThreads() []*phpThread {
148148 worker .threadMutex .RLock ()
149149 ready .Add (len (worker .threads ))
150150 for _ , thread := range worker .threads {
151- if ! thread .state .requestSafeStateChange (stateRestarting ) {
152- ready .Done ()
153- // no state change allowed == thread is shutting down
154- // we'll proceed to restart all other threads anyways
155- continue
156- }
157- close (thread .drainChan )
158- drainedThreads = append (drainedThreads , thread )
159151 go func (thread * phpThread ) {
160- thread .state . waitFor ( stateYielding )
152+ thread .restart ( )
161153 ready .Done ()
162154 }(thread )
163155 }
You can’t perform that action at this time.
0 commit comments