THRIFT-1067. php: Tons of bugs in php implementation
Patch: Ruslan Usifov
git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1073444 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/php/src/transport/TSocket.php b/lib/php/src/transport/TSocket.php
index 6fd4825..8297631 100644
--- a/lib/php/src/transport/TSocket.php
+++ b/lib/php/src/transport/TSocket.php
@@ -250,7 +250,12 @@
throw new TTransportException('TSocket: Could not read '.$len.' bytes from '.
$this->host_.':'.$this->port_);
}
- } else if (($sz = strlen($buf)) < $len) {
+ }
+ else if (($sz = strlen($buf)) < $len) {
+ if((strlen($buf) == 0) && feof($this->handle_)){
+ throw new TTransportException('TSocket read 0 bytes');
+ };
+
$md = stream_get_meta_data($this->handle_);
if (true === $md['timed_out'] && false === $md['blocked']) {
throw new TTransportException('TSocket: timed out reading '.$len.' bytes from '.
@@ -287,6 +292,10 @@
$this->host_.':'.$this->port_);
}
}
+ elseif((strlen($data) == 0) && feof($this->handle_))
+ {
+ throw new TTransportException('TSocket read 0 bytes');
+ };
return $data;
}