aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Enderlin <ivan.enderlin@hoa-project.net>2016-08-04 08:29:50 +0200
committerIvan Enderlin <ivan.enderlin@hoa-project.net>2016-08-04 08:29:50 +0200
commitde5e6506b6c0db10c12f633f75e7177f0b877c2b (patch)
treef19214ac4458110758c867a15559bc7692098fa1
parent3eca29893c40e8dedad0e30ee5f1cc55e764f579 (diff)
downloadWebsocket-de5e6506b6c0db10c12f633f75e7177f0b877c2b.zip
Websocket-de5e6506b6c0db10c12f633f75e7177f0b877c2b.tar.gz
Websocket-de5e6506b6c0db10c12f633f75e7177f0b877c2b.tar.bz2
Connection: Ensure disconnection on closing.
If the node is not able to close properly, then the socket disconnection was not happening nicely. This patch catches errors from a node closing and ensure the socket disconnection all the time.
-rw-r--r--Connection.php10
1 files changed, 7 insertions, 3 deletions
diff --git a/Connection.php b/Connection.php
index bf84deb..75899fe 100644
--- a/Connection.php
+++ b/Connection.php
@@ -573,10 +573,14 @@ abstract class Connection
$connection = $this->getConnection();
$protocol = $connection->getCurrentNode()->getProtocolImplementation();
- if (null !== $protocol) {
- $protocol->close($code, $reason);
+ try {
+ if (null !== $protocol) {
+ $protocol->close($code, $reason);
+ }
+ } finally {
+ $out = $connection->disconnect();
}
- return $connection->disconnect();
+ return $out;
}
}