ideawu / ssdb

SSDB - A fast NoSQL database, an alternative to Redis
http://ssdb.io/
BSD 3-Clause "New" or "Revised" License
8.19k stars 1.4k forks source link

[announce] SSDB.php bug on fwrite() #690

Closed ideawu closed 9 years ago

ideawu commented 9 years ago

An important bug fix is made:

--- a/api/php/SSDB.php
+++ b/api/php/SSDB.php
@@ -506,7 +506,7 @@ class SSDB
                try{
                        while(true){
                                $ret = @fwrite($this->sock, $s);
-                               if($ret === false){
+                               if($ret === false || $ret === 0){
                                        $this->close();
                                        throw new SSDBException('Connection lost');
                                }

Because fwrite() will returns 0 on error!

ideawu commented 9 years ago

If you are using(in some old versions)

if($ret == false){

It works exactly right! No worry.