mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-22 13:30:55 +01:00
Prevent Phabot from spinning out of control
Summary: When the remote closes the connection, phabot goes into a busy loop because of PHP's "nothing should ever be an error" semantics. Instead, detect connection termination. Test Plan: Disabled the "PONG" response in the protocol handler and let freenode disconnect phabot. It spun out of control before, now it detects the issue and exits to await automatic restart. Reviewed By: jungejason Reviewers: codeblock, jungejason, aran, tuomaspelkonen CC: aran, jungejason Differential Revision: 582
This commit is contained in:
parent
cd47271cf5
commit
39adae9aa8
1 changed files with 8 additions and 0 deletions
|
@ -130,6 +130,14 @@ final class PhabricatorIRCBot extends PhabricatorDaemon {
|
|||
}
|
||||
|
||||
if ($read) {
|
||||
// Test for connection termination; in PHP, fread() off a nonblocking,
|
||||
// closed socket is empty string.
|
||||
if (feof($this->socket)) {
|
||||
// This indicates the connection was terminated on the other side,
|
||||
// just exit via exception and let the overseer restart us after a
|
||||
// delay so we can reconnect.
|
||||
throw new Exception("Remote host closed connection.");
|
||||
}
|
||||
do {
|
||||
$data = fread($this->socket, 4096);
|
||||
if ($data === false) {
|
||||
|
|
Loading…
Reference in a new issue