Thrift: Fix PHP socket fread return
authorMark Slee <mcslee@apache.org>
Tue, 21 Nov 2006 02:01:22 +0000 (02:01 +0000)
committerMark Slee <mcslee@apache.org>
Tue, 21 Nov 2006 02:01:22 +0000 (02:01 +0000)
Summary: If you read the string "0" then it treats that as false, so we have to check for both === false and === '' manually.

Reviewed By: martin

Notes: I hate php

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@664878 13f79535-47bb-0310-9956-ffa450edef68

lib/php/src/transport/TSocket.php

index d05f351..3dc643c 100644 (file)
@@ -171,7 +171,7 @@ class TSocket extends TTransport {
     $pre = null;
     while (TRUE) {
       $buf = @fread($this->handle_, $len);
-      if (!$buf) {
+      if ($buf === FALSE || $buf === '') {
         throw new Exception('TSocket: Could not read '.$len.' bytes from '.
                             $this->host_.':'.$this->port_);
       } else if (($sz = strlen($buf)) < $len) {
@@ -201,7 +201,7 @@ class TSocket extends TTransport {
       $this->sendTimeoutSet_ = FALSE;
     }
     $data = @fread($this->handle_, $len);
-    if (!$data) {
+    if ($data === FALSE || $data === '') {
       throw new Exception('TSocket: Could not read '.$len.' bytes from '.
                           $this->host_.':'.$this->port_);
     }