THRIFT-5199: Fix infinite loop writing to closed TSocket in PHP
Client: php
Patch: Tim Heilig
This closes #2134
diff --git a/lib/php/lib/Transport/TSocket.php b/lib/php/lib/Transport/TSocket.php
index 5147efa..374037a 100644
--- a/lib/php/lib/Transport/TSocket.php
+++ b/lib/php/lib/Transport/TSocket.php
@@ -328,7 +328,8 @@
if ($writable > 0) {
// write buffer to stream
$written = fwrite($this->handle_, $buf);
- if ($written === -1 || $written === false) {
+ $closed_socket = $written === 0 && feof($this->handle_);
+ if ($written === -1 || $written === false || $closed_socket) {
throw new TTransportException(
'TSocket: Could not write ' . TStringFuncFactory::create()->strlen($buf) . ' bytes ' .
$this->host_ . ':' . $this->port_