Browse Source

Change network resource handling in the internals of Predis\Connection.

Daniele Alessandri 14 years ago
parent
commit
235d311cb1
1 changed files with 5 additions and 3 deletions
  1. 5 3
      lib/Predis.php

+ 5 - 3
lib/Predis.php

@@ -1333,7 +1333,7 @@ class Connection implements IConnection {
     }
 
     public function isConnected() {
-        return is_resource($this->_socket);
+        return isset($this->_socket);
     }
 
     public function connect() {
@@ -1395,6 +1395,7 @@ class Connection implements IConnection {
     public function disconnect() {
         if ($this->isConnected()) {
             fclose($this->_socket);
+            unset($this->_socket);
         }
     }
 
@@ -1490,9 +1491,10 @@ class Connection implements IConnection {
     }
 
     public function getSocket() {
-        if (!$this->isConnected()) {
-            $this->connect();
+        if (isset($this->_socket)) {
+            return $this->_socket;
         }
+        $this->connect();
         return $this->_socket;
     }