API Index — Namespaces, Packages, Reports, Indices
ZealPHP_Pool_State
in package
Loop control and the response channel, kept out of the included script's reach (C1).
The request include runs at GLOBAL scope (legacy apps need their top-level
variables to be real globals), so anything the loop keeps in a global the
script can overwrite. These used to be $__pw_max_requests, $__pw_count,
$__pw_fd3 and $__pw_mid_request: nulling $__pw_fd3 sent the response
down a channel the parent no longer reads, and rewinding $__pw_count
defeated the recycle. Private statics of a final class cannot be reached by
ordinary code. (Reflection can still reach them: this guards against bugs,
not against a hostile script, which the pool does not claim to contain.)
The class also carries the per-request token the parent sends with every request frame. Every response frame echoes it, so the parent can tell its own subprocess's frame from bytes some script wrote to fd 3.
#467 — $__pw_count / $__pw_max_requests were themselves the fix for an
unprefixed $count the included app clobbered; moving them here closes the
same hole for good.
Table of Contents
Properties
- $count : int
- $fd3 : resource|null
- $maxRequests : int
- $midRequest : bool
- $token : string
Methods
- boot() : void
- midRequest() : bool
- more() : bool
- read() : array<string|int, mixed>|null
- Read the next request frame. The token is taken out and kept here, so the included script never sees it.
- respond() : void
- Send the response for the current request (metadata frame, then body) and leave the mid-request state. Called once per request: by the loop, or by ZealPHP_IPC_Sender's destructor when exit() cut the request short.
- served() : void
Properties
$count
private
static int
$count
= 0
$fd3
private
static resource|null
$fd3
= \null
$maxRequests
private
static int
$maxRequests
= 500
$midRequest
private
static bool
$midRequest
= \false
$token
private
static string
$token
= ''
Methods
boot()
public
static boot() : void
midRequest()
public
static midRequest() : bool
Return values
boolmore()
public
static more() : bool
Return values
boolread()
Read the next request frame. The token is taken out and kept here, so the included script never sees it.
public
static read() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|nullrespond()
Send the response for the current request (metadata frame, then body) and leave the mid-request state. Called once per request: by the loop, or by ZealPHP_IPC_Sender's destructor when exit() cut the request short.
public
static respond(array<string|int, mixed> $resp, string $body) : void
Parameters
- $resp : array<string|int, mixed>
- $body : string
served()
public
static served() : void