@@ -160,8 +160,7 @@ discard block |
||
160 | 160 | |
161 | 161 | if ($pid === -1) { |
162 | 162 | throw new Exception('Could not fork'); |
163 | - } |
|
164 | - elseif ($pid === 0) { // we are the child |
|
163 | + } elseif ($pid === 0) { // we are the child |
|
165 | 164 | $thread = $this; |
166 | 165 | $thread->pid = posix_getpid(); |
167 | 166 | if (!$thread->delayedSigReg) { |
@@ -187,8 +186,7 @@ discard block |
||
187 | 186 | protected function sighandler($signo) { |
188 | 187 | if (is_callable($c = array($this, strtolower(self::$signals[$signo])))) { |
189 | 188 | call_user_func($c); |
190 | - } |
|
191 | - elseif (is_callable($c = array($this, 'sigunknown'))) { |
|
189 | + } elseif (is_callable($c = array($this, 'sigunknown'))) { |
|
192 | 190 | call_user_func($c, $signo); |
193 | 191 | } |
194 | 192 | } |
@@ -116,12 +116,10 @@ discard block |
||
116 | 116 | if (isset($e[1])) { |
117 | 117 | $currentHeader = 'HTTP_' . strtoupper(strtr($e[0], HTTPRequest::$htr)); |
118 | 118 | $req->attrs->server[$currentHeader] = $e[1]; |
119 | - } |
|
120 | - elseif ($e[0][0] === "\t" || $e[0][0] === "\x20") |
|
119 | + } elseif ($e[0][0] === "\t" || $e[0][0] === "\x20") |
|
121 | 120 | { // multiline header continued |
122 | 121 | $req->attrs->server[$currentHeader] .= $e[0]; |
123 | - } |
|
124 | - else |
|
122 | + } else |
|
125 | 123 | { // whatever client speaks is not HTTP anymore |
126 | 124 | $this->finish(); |
127 | 125 | return; |
@@ -168,8 +166,7 @@ discard block |
||
168 | 166 | } |
169 | 167 | $this->state = self::STATE_CONTENT; |
170 | 168 | } |
171 | - } |
|
172 | - else { |
|
169 | + } else { |
|
173 | 170 | $this->bufHead = $buf; |
174 | 171 | goto start; |
175 | 172 | } |
@@ -197,11 +194,9 @@ discard block |
||
197 | 194 | $char = $this->pool->variablesOrder[$i]; |
198 | 195 | if ($char == 'G') { |
199 | 196 | $req->attrs->request += $req->attrs->get; |
200 | - } |
|
201 | - elseif ($char == 'P') { |
|
197 | + } elseif ($char == 'P') { |
|
202 | 198 | $req->attrs->request += $req->attrs->post; |
203 | - } |
|
204 | - elseif ($char == 'C') { |
|
199 | + } elseif ($char == 'C') { |
|
205 | 200 | $req->attrs->request += $req->attrs->cookie; |
206 | 201 | } |
207 | 202 | } |
@@ -112,9 +112,11 @@ discard block |
||
112 | 112 | $this->state = self::STATE_ROOT; |
113 | 113 | |
114 | 114 | |
115 | - if (0) Daemon::log('[DEBUG] FastCGI-record ' . $this->header['ttype'] . '). Request ID: ' . $rid |
|
115 | + if (0) { |
|
116 | + Daemon::log('[DEBUG] FastCGI-record ' . $this->header['ttype'] . '). Request ID: ' . $rid |
|
116 | 117 | . '. Content length: ' . $this->header['conlen'] . ' (' . strlen($this->content) . ') Padding length: ' . $this->header['padlen'] |
117 | 118 | . ' (' . strlen($pad) . ')'); |
119 | + } |
|
118 | 120 | |
119 | 121 | |
120 | 122 | if ($type == self::FCGI_BEGIN_REQUEST) { |
@@ -142,8 +144,7 @@ discard block |
||
142 | 144 | $req->queueId = $rid; |
143 | 145 | $req->conn = $this; |
144 | 146 | $this->requests[$rid] = $req; |
145 | - } |
|
146 | - elseif (isset($this->requests[$rid])) { |
|
147 | + } elseif (isset($this->requests[$rid])) { |
|
147 | 148 | $req = $this->requests[$rid]; |
148 | 149 | } else { |
149 | 150 | Daemon::log('Unexpected FastCGI-record #' . $this->header['type'] . ' (' . $this->header['ttype'] . '). Request ID: ' . $rid . '.'); |
@@ -152,8 +153,7 @@ discard block |
||
152 | 153 | |
153 | 154 | if ($type === self::FCGI_ABORT_REQUEST) { |
154 | 155 | $req->abort(); |
155 | - } |
|
156 | - elseif ($type === self::FCGI_PARAMS) { |
|
156 | + } elseif ($type === self::FCGI_PARAMS) { |
|
157 | 157 | if ($this->content === '') { |
158 | 158 | if (!isset($req->attrs->server['REQUEST_TIME'])) { |
159 | 159 | $req->attrs->server['REQUEST_TIME'] = time(); |
@@ -213,8 +213,7 @@ discard block |
||
213 | 213 | $p += $namelen + $vlen; |
214 | 214 | } |
215 | 215 | } |
216 | - } |
|
217 | - elseif ($type === self::FCGI_STDIN) { |
|
216 | + } elseif ($type === self::FCGI_STDIN) { |
|
218 | 217 | if ($this->content === '') { |
219 | 218 | $req->attrs->stdin_done = true; |
220 | 219 | } |
@@ -234,11 +233,9 @@ discard block |
||
234 | 233 | |
235 | 234 | if ($char == 'G') { |
236 | 235 | $req->attrs->request += $req->attrs->get; |
237 | - } |
|
238 | - elseif ($char == 'P') { |
|
236 | + } elseif ($char == 'P') { |
|
239 | 237 | $req->attrs->request += $req->attrs->post; |
240 | - } |
|
241 | - elseif ($char == 'C') { |
|
238 | + } elseif ($char == 'C') { |
|
242 | 239 | $req->attrs->request += $req->attrs->cookie; |
243 | 240 | } |
244 | 241 | } |
@@ -349,8 +346,7 @@ discard block |
||
349 | 346 | |
350 | 347 | if ($protoStatus === -1) { |
351 | 348 | $this->close(); |
352 | - } |
|
353 | - elseif (!$this->pool->config->keepalive->value) { |
|
349 | + } elseif (!$this->pool->config->keepalive->value) { |
|
354 | 350 | $this->finish(); |
355 | 351 | } |
356 | 352 | } |
@@ -36,11 +36,9 @@ discard block |
||
36 | 36 | public function onConnected($cb) { |
37 | 37 | if ($this->state == self::STATE_AUTH_ERR) { |
38 | 38 | call_user_func($cb, $this, FALSE); |
39 | - } |
|
40 | - elseif ($this->state === self::STATE_HANDSHAKED) { |
|
39 | + } elseif ($this->state === self::STATE_HANDSHAKED) { |
|
41 | 40 | call_user_func($cb, $this, TRUE); |
42 | - } |
|
43 | - else { |
|
41 | + } else { |
|
44 | 42 | if (!$this->onConnected) { |
45 | 43 | $this->onConnected = new StackCallbacks; |
46 | 44 | } |
@@ -401,8 +399,7 @@ discard block |
||
401 | 399 | $this->onError(); |
402 | 400 | $this->errno = 0; |
403 | 401 | $this->errmsg = ''; |
404 | - } |
|
405 | - elseif ($fieldCount === 0x00) { |
|
402 | + } elseif ($fieldCount === 0x00) { |
|
406 | 403 | // OK Packet Empty |
407 | 404 | if ($this->state === self::STATE_AUTH_SENT) { |
408 | 405 | $this->state = self::STATE_HANDSHAKED; |
@@ -428,13 +425,11 @@ discard block |
||
428 | 425 | |
429 | 426 | $this->message = binarySubstr($this->buf, $p, $packet[0] + 4 - $p); |
430 | 427 | $this->onResultDone(); |
431 | - } |
|
432 | - elseif ($fieldCount === 0xFE) { |
|
428 | + } elseif ($fieldCount === 0xFE) { |
|
433 | 429 | // EOF Packet |
434 | 430 | if ($this->instate === self::INSTATE_ROW) { |
435 | 431 | $this->onResultDone(); |
436 | - } |
|
437 | - else { |
|
432 | + } else { |
|
438 | 433 | ++$this->instate; |
439 | 434 | } |
440 | 435 | } else { |
@@ -445,8 +440,7 @@ discard block |
||
445 | 440 | // Result Set Header Packet |
446 | 441 | $extra = $this->parseEncodedBinary($this->buf, $p); |
447 | 442 | $this->instate = self::INSTATE_FIELD; |
448 | - } |
|
449 | - elseif ($this->instate === self::INSTATE_FIELD) { |
|
443 | + } elseif ($this->instate === self::INSTATE_FIELD) { |
|
450 | 444 | // Field Packet |
451 | 445 | $field = array( |
452 | 446 | 'catalog' => $this->parseEncodedString($this->buf, $p), |
@@ -478,8 +472,7 @@ discard block |
||
478 | 472 | ++$p; |
479 | 473 | |
480 | 474 | $this->resultFields[] = $field; |
481 | - } |
|
482 | - elseif ($this->instate === self::INSTATE_ROW) { |
|
475 | + } elseif ($this->instate === self::INSTATE_ROW) { |
|
483 | 476 | // Row Packet |
484 | 477 | $row = array(); |
485 | 478 |
@@ -136,8 +136,7 @@ |
||
136 | 136 | unset($this->pool->cursors[$cur]); |
137 | 137 | } |
138 | 138 | } |
139 | - } |
|
140 | - elseif (isset($this->pool->cursors[$cur])) { |
|
139 | + } elseif (isset($this->pool->cursors[$cur])) { |
|
141 | 140 | call_user_func($this->pool->cursors[$cur]->callback, $this->pool->cursors[$cur]); |
142 | 141 | } |
143 | 142 |
@@ -99,8 +99,7 @@ discard block |
||
99 | 99 | foreach ($this->locks as $name => $status) { |
100 | 100 | if ($status === 1) { |
101 | 101 | $this->done($name, 'FAILED'); |
102 | - } |
|
103 | - elseif ($status === 2) { |
|
102 | + } elseif ($status === 2) { |
|
104 | 103 | unset($this->pool->lockConnState[$name][$this->connId]); |
105 | 104 | } |
106 | 105 | } |
@@ -121,20 +120,15 @@ discard block |
||
121 | 120 | |
122 | 121 | if ($e[0] === 'acquire') { |
123 | 122 | $this->writeln($this->acquireLock($e[1]) . ' ' . $e[1]); |
124 | - } |
|
125 | - elseif ($e[0] === 'acquireWait') { |
|
123 | + } elseif ($e[0] === 'acquireWait') { |
|
126 | 124 | $this->writeln($this->acquireLock($e[1], TRUE) . ' ' . $e[1]); |
127 | - } |
|
128 | - elseif ($e[0] === 'done') { |
|
125 | + } elseif ($e[0] === 'done') { |
|
129 | 126 | $this->done($e[1], 'DONE'); |
130 | - } |
|
131 | - elseif ($e[0] === 'failed') { |
|
127 | + } elseif ($e[0] === 'failed') { |
|
132 | 128 | $this->done($e[1], 'FAILED'); |
133 | - } |
|
134 | - elseif ($e[0] === 'quit') { |
|
129 | + } elseif ($e[0] === 'quit') { |
|
135 | 130 | $this->finish(); |
136 | - } |
|
137 | - elseif ($e[0] !== '') { |
|
131 | + } elseif ($e[0] !== '') { |
|
138 | 132 | $this->writeln('PROTOCOL_ERROR'); |
139 | 133 | } |
140 | 134 | if($this->pool->config->protologging->value) { |
@@ -184,8 +184,7 @@ discard block |
||
184 | 184 | if (is_callable(array($this->upstream, 'onHandshake'))) { |
185 | 185 | $this->upstream->onHandshake(); |
186 | 186 | } |
187 | - } |
|
188 | - else { |
|
187 | + } else { |
|
189 | 188 | Daemon::$process->log(get_class($this) . '::' . __METHOD__ . ' : Handshake send failure for client "' . $this->addr . '"') ; |
190 | 189 | $this->finish(); |
191 | 190 | return false; |
@@ -247,29 +246,24 @@ discard block |
||
247 | 246 | if (isset($this->server['HTTP_SEC_WEBSOCKET_VERSION'])) { // HYBI |
248 | 247 | if ($this->server['HTTP_SEC_WEBSOCKET_VERSION'] == '8') { // Version 8 (FF7, Chrome14) |
249 | 248 | $this->protocol = new WebSocketProtocolV13($this) ; |
250 | - } |
|
251 | - elseif ($this->server['HTTP_SEC_WEBSOCKET_VERSION'] == '13') { // newest protocol |
|
249 | + } elseif ($this->server['HTTP_SEC_WEBSOCKET_VERSION'] == '13') { // newest protocol |
|
252 | 250 | $this->protocol = new WebSocketProtocolV13($this); |
253 | - } |
|
254 | - else |
|
251 | + } else |
|
255 | 252 | { |
256 | 253 | Daemon::$process->log(get_class($this) . '::' . __METHOD__ . " : Websocket protocol version " . $this->server['HTTP_SEC_WEBSOCKET_VERSION'] . ' is not yet supported for client "' . $this->addr . '"') ; |
257 | 254 | |
258 | 255 | $this->finish(); |
259 | 256 | return; |
260 | 257 | } |
261 | - } |
|
262 | - elseif (!isset($this->server['HTTP_SEC_WEBSOCKET_KEY1']) || !isset($this->server['HTTP_SEC_WEBSOCKET_KEY2'])) { |
|
258 | + } elseif (!isset($this->server['HTTP_SEC_WEBSOCKET_KEY1']) || !isset($this->server['HTTP_SEC_WEBSOCKET_KEY2'])) { |
|
263 | 259 | $this->protocol = new WebSocketProtocolVE($this); |
264 | - } |
|
265 | - else { // Defaulting to HIXIE (Safari5 and many non-browser clients...) |
|
260 | + } else { // Defaulting to HIXIE (Safari5 and many non-browser clients...) |
|
266 | 261 | $this->protocol = new WebSocketProtocolV0($this) ; |
267 | 262 | } |
268 | 263 | // ---------------------------------------------------------- |
269 | 264 | // End of protocol discovery |
270 | 265 | // ---------------------------------------------------------- |
271 | - } |
|
272 | - elseif (!$this->firstline) |
|
266 | + } elseif (!$this->firstline) |
|
273 | 267 | { |
274 | 268 | $this->firstline = true; |
275 | 269 | $e = explode(' ', $l); |
@@ -284,8 +278,7 @@ discard block |
||
284 | 278 | $this->server['SERVER_PROTOCOL'] = isset($e[2]) ? trim($e[2]) : ''; |
285 | 279 | |
286 | 280 | list($this->server['REMOTE_ADDR'],$this->server['REMOTE_PORT']) = explode(':', $this->addr); |
287 | - } |
|
288 | - else |
|
281 | + } else |
|
289 | 282 | { |
290 | 283 | $e = explode(': ', $l); |
291 | 284 |
@@ -113,13 +113,11 @@ |
||
113 | 113 | if (isset($this->pool->jobs[$e[1]])) { |
114 | 114 | call_user_func($this->pool->jobs[$e[1]][0], $e[0], $e[1], $this->pool); |
115 | 115 | } |
116 | - } |
|
117 | - elseif ($e[0] === 'DONE') { |
|
116 | + } elseif ($e[0] === 'DONE') { |
|
118 | 117 | if (isset($this->pool->jobs[$e[1]][1])) { |
119 | 118 | call_user_func($this->pool->jobs[$e[1]][1], $e[0], $e[1], $this->pool); |
120 | 119 | } |
121 | - } |
|
122 | - elseif ($e[0] === 'FAILED') { |
|
120 | + } elseif ($e[0] === 'FAILED') { |
|
123 | 121 | if (isset($this->pool->jobs[$e[1]][2])) { |
124 | 122 | call_user_func($this->pool->jobs[$e[1]][2], $e[0], $e[1], $this->pool); |
125 | 123 | } |
@@ -69,8 +69,7 @@ discard block |
||
69 | 69 | } |
70 | 70 | if (!isset($worker->instancesCount[$name])) { |
71 | 71 | $worker->instancesCount[$name] = 1; |
72 | - } |
|
73 | - else { |
|
72 | + } else { |
|
74 | 73 | ++$worker->instancesCount[$name]; |
75 | 74 | } |
76 | 75 | $worker->sendPacket(array('op' => 'spawnInstance', 'appfullname' => $name)); |
@@ -160,22 +159,19 @@ discard block |
||
160 | 159 | $this->workerId = $p['workerId']; |
161 | 160 | $this->pool->workers[$this->workerId] = $this; |
162 | 161 | $this->pool->appInstance->updatedWorkers(); |
163 | - } |
|
164 | - elseif ($p['op'] === 'broadcastCall') { |
|
162 | + } elseif ($p['op'] === 'broadcastCall') { |
|
165 | 163 | $p['op'] = 'call'; |
166 | 164 | foreach ($this->pool->workers as $worker) { |
167 | 165 | $worker->sendPacket($p); |
168 | 166 | } |
169 | - } |
|
170 | - elseif ($p['op'] === 'directCall') { |
|
167 | + } elseif ($p['op'] === 'directCall') { |
|
171 | 168 | $p['op'] = 'call'; |
172 | 169 | if (!isset($this->pool->workers[$p['workerId']])) { |
173 | 170 | Daemon::$process->log('directCall(). not sent.'); |
174 | 171 | return; |
175 | 172 | } |
176 | 173 | $this->pool->workers[$p['workerId']]->sendPacket($p); |
177 | - } |
|
178 | - elseif ($p['op'] === 'singleCall') { |
|
174 | + } elseif ($p['op'] === 'singleCall') { |
|
179 | 175 | $p['op'] = 'call'; |
180 | 176 | $sent = false; |
181 | 177 | foreach ($this->pool->workers as $worker) { |
@@ -186,8 +182,7 @@ discard block |
||
186 | 182 | if (!$sent) { |
187 | 183 | Daemon::$process->log('singleCall(). not sent.'); |
188 | 184 | } |
189 | - } |
|
190 | - elseif ($p['op'] === 'addIncludedFiles') { |
|
185 | + } elseif ($p['op'] === 'addIncludedFiles') { |
|
191 | 186 | foreach ($p['files'] as $file) { |
192 | 187 | Daemon::$process->fileWatcher->addWatch($file, $this->workerId); |
193 | 188 | } |
@@ -253,8 +248,7 @@ discard block |
||
253 | 248 | } |
254 | 249 | list($app, $name) = explode(':', $fullname, 2); |
255 | 250 | Daemon::$appResolver->appInstantiate($app,$name); |
256 | - } |
|
257 | - elseif ($p['op'] === 'importFile') { |
|
251 | + } elseif ($p['op'] === 'importFile') { |
|
258 | 252 | if (!Daemon::$config->autoreimport->value) { |
259 | 253 | Daemon::$process->sigusr2(); // graceful restart |
260 | 254 | return; |
@@ -273,8 +267,7 @@ discard block |
||
273 | 267 | |
274 | 268 | $event->finish(); |
275 | 269 | }, 5); |
276 | - } |
|
277 | - elseif ($p['op'] === 'call') { |
|
270 | + } elseif ($p['op'] === 'call') { |
|
278 | 271 | if (strpos($p['appfullname'],':') === false) { |
279 | 272 | $p['appfullname'] .= ':'; |
280 | 273 | } |