Skip to content

Commit

Permalink
Prevent exception inside handleDisconnect() and handleError()
Browse files Browse the repository at this point in the history
  • Loading branch information
thekid committed Jan 12, 2025
1 parent 274bc84 commit ebfb5dd
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/main/php/xp/web/srv/Protocol.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,10 @@ public function handleData($socket) {
*/
public function handleDisconnect($socket) {
$handle= spl_object_id($socket);
$this->protocols[$handle]->handleDisconnect($socket);

unset($this->protocols[$handle]);
if (isset($this->protocols[$handle])) {
$this->protocols[$handle]->handleDisconnect($socket);
unset($this->protocols[$handle]);
}
$socket->close();
}

Expand All @@ -94,9 +95,10 @@ public function handleDisconnect($socket) {
*/
public function handleError($socket, $e) {
$handle= spl_object_id($socket);
$this->protocols[$handle]->handleError($socket, $e);

unset($this->protocols[$handle]);
if (isset($this->protocols[$handle])) {
$this->protocols[$handle]->handleError($socket, $e);
unset($this->protocols[$handle]);
}
$socket->close();
}
}

0 comments on commit ebfb5dd

Please sign in to comment.