@@ -116,9 +116,7 @@ |
||
116 | 116 | public function getRequest($req, $upstream, $defaultApp = NULL) { |
117 | 117 | if (isset($req->attrs->server['APPNAME'])) { |
118 | 118 | $appName = $req->attrs->server['APPNAME']; |
119 | - } |
|
120 | - elseif (($appName = $this->getRequestRoute($req, $upstream)) !== NULL) {} |
|
121 | - else { |
|
119 | + } elseif (($appName = $this->getRequestRoute($req, $upstream)) !== NULL) {} else { |
|
122 | 120 | $appName = $defaultApp; |
123 | 121 | } |
124 | 122 | if (strpos($appName,'-') === false) { |
@@ -65,8 +65,7 @@ discard block |
||
65 | 65 | $readFD = FALSE; |
66 | 66 | } |
67 | 67 | } |
68 | - } |
|
69 | - elseif ( |
|
68 | + } elseif ( |
|
70 | 69 | ($u['scheme'] === 'tcp') |
71 | 70 | || ($u['scheme'] === 'tcpstream') |
72 | 71 | ) { |
@@ -83,8 +82,7 @@ discard block |
||
83 | 82 | $readFD = FALSE; |
84 | 83 | } |
85 | 84 | } |
86 | - } |
|
87 | - elseif ($u['scheme'] === 'udp') { |
|
85 | + } elseif ($u['scheme'] === 'udp') { |
|
88 | 86 | if (!$this->useSockets) { |
89 | 87 | $readFD = stream_socket_client($readFD, $errno, $errstr, 1); |
90 | 88 | } else { |
@@ -95,8 +93,7 @@ discard block |
||
95 | 93 | $readFD = FALSE; |
96 | 94 | } |
97 | 95 | } |
98 | - } |
|
99 | - elseif ($u['scheme'] === 'file') { |
|
96 | + } elseif ($u['scheme'] === 'file') { |
|
100 | 97 | $this->filePath = substr($url, 7); |
101 | 98 | $readFD = @fopen($this->filePath, 'r'); |
102 | 99 | $this->fileMode = TRUE; |
@@ -435,8 +432,7 @@ discard block |
||
435 | 432 | ) |
436 | 433 | ) { |
437 | 434 | $this->onEofEvent(); |
438 | - } |
|
439 | - elseif ( |
|
435 | + } elseif ( |
|
440 | 436 | !$this->EOF |
441 | 437 | && $this->noEvents |
442 | 438 | ) { |
@@ -461,8 +457,7 @@ discard block |
||
461 | 457 | } |
462 | 458 | |
463 | 459 | $this->eof(); |
464 | - } |
|
465 | - elseif ($this->onRead !== NULL) { |
|
460 | + } elseif ($this->onRead !== NULL) { |
|
466 | 461 | call_user_func($this->onRead, $this); |
467 | 462 | } |
468 | 463 | } |
@@ -134,12 +134,10 @@ discard block |
||
134 | 134 | $r = ''; |
135 | 135 | if (strlen($p) < $s) { |
136 | 136 | echo("getLV error: buf length (".strlen($p)."): ".Debug::exportBytes($p).", must be >= string length (".$s.")\n"); |
137 | - } |
|
138 | - elseif ($nul) { |
|
137 | + } elseif ($nul) { |
|
139 | 138 | if ($p{$s-1} != "\x00") { |
140 | 139 | echo("getLV error: Wrong end of NUL-string (".Debug::exportBytes($p{$s-1})."), len ".$s."\n"); |
141 | - } |
|
142 | - else { |
|
140 | + } else { |
|
143 | 141 | $d = $s-1; |
144 | 142 | if ($d < 0) { |
145 | 143 | $d = 0; |
@@ -147,8 +145,7 @@ discard block |
||
147 | 145 | $r = binarySubstr($p, 0, $d); |
148 | 146 | $p = binarySubstr($p, $s); |
149 | 147 | } |
150 | - } |
|
151 | - else { |
|
148 | + } else { |
|
152 | 149 | $r = binarySubstr($p, 0, $s); |
153 | 150 | $p = binarySubstr($p, $s); |
154 | 151 | } |
@@ -161,8 +158,7 @@ discard block |
||
161 | 158 | if (strlen($hexstr) % 2) { |
162 | 159 | $hexstr = "0".$hexstr; |
163 | 160 | } |
164 | - } |
|
165 | - else { |
|
161 | + } else { |
|
166 | 162 | $hexstr = str_repeat('0', $len * 2 - strlen($hexstr)) . $hexstr; |
167 | 163 | } |
168 | 164 | $bytes = strlen($hexstr)/2; |
@@ -63,11 +63,13 @@ |
||
63 | 63 | $set['players'] = $job->results['players']; |
64 | 64 | $set['latency'] = $job->results['latency']; |
65 | 65 | $set['atime'] = time(); |
66 | - if (0) Daemon::log('Updated server ('.round(memory_get_usage(true)/1024/1024, 5).'): '.$server['address']. ' latency = '.round($set['latency'] * 1000, 2).' ==== ' |
|
66 | + if (0) { |
|
67 | + Daemon::log('Updated server ('.round(memory_get_usage(true)/1024/1024, 5).'): '.$server['address']. ' latency = '.round($set['latency'] * 1000, 2).' ==== ' |
|
67 | 68 | . (isset($server['atime']) ? |
68 | 69 | round($set['atime'] - $server['atime']) . ' secs. from last update.' |
69 | 70 | : ' =---= '.json_encode($server)) |
70 | 71 | ); |
72 | + } |
|
71 | 73 | try { |
72 | 74 | $app->servers->upsert(array('_id' => $server['_id']), array('$set' => $set)); |
73 | 75 | } catch (MongoException $e) { |
@@ -87,8 +87,7 @@ discard block |
||
87 | 87 | if (posix_getuid() != 0) { |
88 | 88 | $this->log('You must have the root privileges to change root.'); |
89 | 89 | exit(0); |
90 | - } |
|
91 | - elseif (!chroot(Daemon::$config->chroot->value)) { |
|
90 | + } elseif (!chroot(Daemon::$config->chroot->value)) { |
|
92 | 91 | Daemon::log('Couldn\'t change root to \'' . Daemon::$config->chroot->value . '\'.'); |
93 | 92 | exit(0); |
94 | 93 | } |
@@ -98,8 +97,7 @@ discard block |
||
98 | 97 | if ($sg === FALSE) { |
99 | 98 | $this->log('Couldn\'t change group to \'' . Daemon::$config->group->value . '\'. You must replace config-variable \'group\' with existing group.'); |
100 | 99 | exit(0); |
101 | - } |
|
102 | - elseif ( |
|
100 | + } elseif ( |
|
103 | 101 | ($sg['gid'] != posix_getgid()) |
104 | 102 | && (!posix_setgid($sg['gid'])) |
105 | 103 | ) { |
@@ -112,8 +110,7 @@ discard block |
||
112 | 110 | if ($su === FALSE) { |
113 | 111 | $this->log('Couldn\'t change user to \'' . Daemon::$config->user->value . '\', user not found. You must replace config-variable \'user\' with existing username.'); |
114 | 112 | exit(0); |
115 | - } |
|
116 | - elseif ( |
|
113 | + } elseif ( |
|
117 | 114 | ($su['uid'] != posix_getuid()) |
118 | 115 | && (!posix_setuid($su['uid'])) |
119 | 116 | ) { |
@@ -58,8 +58,7 @@ discard block |
||
58 | 58 | |
59 | 59 | if ($c === "\x20") { |
60 | 60 | ++$spaces; |
61 | - } |
|
62 | - elseif (ctype_digit($c)) { |
|
61 | + } elseif (ctype_digit($c)) { |
|
63 | 62 | $digits .= $c; |
64 | 63 | } |
65 | 64 | } |
@@ -138,8 +137,7 @@ discard block |
||
138 | 137 | $this->connection->buf = binarySubstr($this->connection->buf, 2 + $len) ; |
139 | 138 | |
140 | 139 | $this->connection->onFrame($decodedData, $frametype); |
141 | - } |
|
142 | - else { |
|
140 | + } else { |
|
143 | 141 | if (($p = strpos($this->connection->buf, "\xFF")) !== FALSE) { |
144 | 142 | if ($this->connection->pool->maxAllowedPacket <= $p - 1) { { |
145 | 143 | // Too big packet |
@@ -151,8 +149,7 @@ discard block |
||
151 | 149 | $this->connection->buf = binarySubstr($this->connection->buf, $p + 1) ; |
152 | 150 | $this->connection->onFrame($decodedData, $frametype); |
153 | 151 | |
154 | - } |
|
155 | - else { |
|
152 | + } else { |
|
156 | 153 | if ($this->connection->pool->maxAllowedPacket <= strlen($this->connection->buf)) |
157 | 154 | { |
158 | 155 | // Too big packet |
@@ -41,8 +41,7 @@ |
||
41 | 41 | } |
42 | 42 | if ($this->busy) { |
43 | 43 | $this->pool->servConnFree[$this->url]->detach($this); |
44 | - } |
|
45 | - else { |
|
44 | + } else { |
|
46 | 45 | $this->pool->servConnFree[$this->url]->attach($this); |
47 | 46 | $this->release(); |
48 | 47 | } |
@@ -70,17 +70,13 @@ discard block |
||
70 | 70 | $k = strtolower($k); |
71 | 71 | if ($k === 'connectionclass') { |
72 | 72 | $this->connectionClass = $v; |
73 | - } |
|
74 | - elseif ($k === 'name') { |
|
73 | + } elseif ($k === 'name') { |
|
75 | 74 | $this->name = $v; |
76 | - } |
|
77 | - elseif ($k === 'allowedclients') { |
|
75 | + } elseif ($k === 'allowedclients') { |
|
78 | 76 | $this->allowedClients = $v; |
79 | - } |
|
80 | - elseif ($k === 'maxallowedpacket') { |
|
77 | + } elseif ($k === 'maxallowedpacket') { |
|
81 | 78 | $this->maxAllowedPacket = (int) $v; |
82 | - } |
|
83 | - elseif ($k === 'maxconcurrency') { |
|
79 | + } elseif ($k === 'maxconcurrency') { |
|
84 | 80 | $this->maxConcurrency = (int) $v; |
85 | 81 | } |
86 | 82 | } |
@@ -136,7 +132,7 @@ discard block |
||
136 | 132 | } |
137 | 133 | } elseif ($v instanceof Daemon_ConfigSection) { |
138 | 134 | // @todo |
139 | - } else { |
|
135 | + } else { |
|
140 | 136 | $current = $this->config->{$k}; |
141 | 137 | if (is_scalar($v)) { |
142 | 138 | $this->config->{$k} = new Daemon_ConfigEntry($v); |
@@ -268,8 +264,7 @@ discard block |
||
268 | 264 | } else { |
269 | 265 | if (stripos($addr,'tcp://') === 0) { |
270 | 266 | $addr = substr($addr, 6); |
271 | - } |
|
272 | - elseif (stripos($addr,'tcp:') === 0) { |
|
267 | + } elseif (stripos($addr,'tcp:') === 0) { |
|
273 | 268 | $addr = substr($addr, 4); |
274 | 269 | } |
275 | 270 | $socket = new BoundTCPSocket($addr, $reuse); |
@@ -78,8 +78,10 @@ discard block |
||
78 | 78 | // only in BSD flavour operating systems via SO_REUSEPORT socket option |
79 | 79 | Daemon::$reusePort = 1 === preg_match("~BSD~i", php_uname('s')); |
80 | 80 | |
81 | - if (Daemon::$reusePort && !defined("SO_REUSEPORT")) |
|
82 | - define("SO_REUSEPORT", 0x200); // FIXME: this is a BSD-only hack |
|
81 | + if (Daemon::$reusePort && !defined("SO_REUSEPORT")) { |
|
82 | + define("SO_REUSEPORT", 0x200); |
|
83 | + } |
|
84 | + // FIXME: this is a BSD-only hack |
|
83 | 85 | } |
84 | 86 | |
85 | 87 | public static function loadModuleIfAbsent($mod) { |
@@ -144,8 +146,7 @@ discard block |
||
144 | 146 | if (!Daemon::$restrictErrorControl) { |
145 | 147 | return; |
146 | 148 | } |
147 | - } |
|
148 | - elseif (!($l & $errno)) { |
|
149 | + } elseif (!($l & $errno)) { |
|
149 | 150 | return; |
150 | 151 | } |
151 | 152 | |
@@ -404,34 +405,28 @@ discard block |
||
404 | 405 | } |
405 | 406 | if ($code === 0) { |
406 | 407 | break 2; |
407 | - } |
|
408 | - elseif ($code === Daemon::WSTATE_IDLE) { |
|
408 | + } elseif ($code === Daemon::WSTATE_IDLE) { |
|
409 | 409 | // idle |
410 | 410 | ++$stat['alive']; |
411 | 411 | ++$stat['idle']; |
412 | - } |
|
413 | - elseif ($code === Daemon::WSTATE_BUSY) { |
|
412 | + } elseif ($code === Daemon::WSTATE_BUSY) { |
|
414 | 413 | // busy |
415 | 414 | ++$stat['alive']; |
416 | 415 | ++$stat['busy']; |
417 | - } |
|
418 | - elseif ($code === Daemon::WSTATE_SHUTDOWN) { |
|
416 | + } elseif ($code === Daemon::WSTATE_SHUTDOWN) { |
|
419 | 417 | // shutdown |
420 | 418 | ++$stat['shutdown']; |
421 | - } |
|
422 | - elseif ($code === Daemon::WSTATE_PREINIT) { |
|
419 | + } elseif ($code === Daemon::WSTATE_PREINIT) { |
|
423 | 420 | // pre-init |
424 | 421 | ++$stat['alive']; |
425 | 422 | ++$stat['preinit']; |
426 | 423 | ++$stat['idle']; |
427 | - } |
|
428 | - elseif ($code === Daemon::WSTATE_WAITINIT) { |
|
424 | + } elseif ($code === Daemon::WSTATE_WAITINIT) { |
|
429 | 425 | // wait-init |
430 | 426 | ++$stat['alive']; |
431 | 427 | ++$stat['waitinit']; |
432 | 428 | ++$stat['idle']; |
433 | - } |
|
434 | - elseif ($code === Daemon::WSTATE_INIT) { // init |
|
429 | + } elseif ($code === Daemon::WSTATE_INIT) { // init |
|
435 | 430 | ++$stat['alive']; |
436 | 431 | ++$stat['init']; |
437 | 432 | ++$stat['idle']; |
@@ -453,8 +448,7 @@ discard block |
||
453 | 448 | $args = func_get_args(); |
454 | 449 | if (sizeof($args) == 1) { |
455 | 450 | $msg = is_scalar($args[0]) ? $args[0] : Debug::dump($args[0]); |
456 | - } |
|
457 | - else { |
|
451 | + } else { |
|
458 | 452 | $msg = Debug::dump($args); |
459 | 453 | } |
460 | 454 |