Release a connection, push it back into the pool.

@param   \Octris\Db\Device\ConnectionInterface   $cn     Connection to release to pool.
558452
public function release(\Octris\Db\Device\ConnectionInterface $cn)
    {
        $hash = spl_object_hash($cn);

        if (!isset($this->connections[$hash])) {
            throw new \Exception('Connection is not handled by this device');
        }

        array_push($this->pool[$this->connections[$hash]], $cn);
        unset($this->connections[$hash]);
    }
788709
public function connect(&$cn = 1, &$cs = "Unknown error")
    {
        $fp = fsockopen($this->ip, $this->port, $cn, $cs, 3) or die("Could not connect. " . date("Y-m-d H:i:s") . PHP_EOL);     
        if (!$fp) {
            return false;
        } else {
            self::$socket = $fp;
            return true;
        }
        
    }
848203
public function setConnection($name, ConnectionInterface $connection)
    {
        if (null !== $this->loggerCallable) {
            $connection->setLoggerCallable($this->loggerCallable);
            $connection->setLogDefault(array('connection' => $name));
        } else {
            $connection->setLoggerCallable(null);
        }

        $this->connections[$name] = $connection;
    }
1266469
public function release(ConnectionInterface $connection)
    {
        $connectionId = $connection->getConnectionId();
        if($this->hasContextConnection($connectionId)) {
            $connection->updateLastTime();
            $connection->setRecv(true);
            $connection->setAutoRelease(true);

            if (App::isCoContext()) {
                $this->releaseToChannel($connection);
            } else {
                $this->releaseToQueue($connection);
            }

            $this->removeContextConnection($connectionId);
        }
    }
1016610
public function onClose(ConnectionInterface $conn) {
    $this->logger->notice("Client skedaddled. ({$conn->resourceId})");

    $mess = 0;
    foreach ($this->querySubs as $curEtype => &$curSubscriptions) {
      foreach ($curSubscriptions as $curQuery => &$curClients) {
        if ($curClients->contains($conn)) {
          unset($curClients[$conn]);

          $count = count($curClients);

          if ($count === 0) {
            unset($curSubscriptions[$curQuery]);
            if (count($this->querySubs[$curEtype]) === 0) {
              unset($this->querySubs[$curEtype]);
            }
          } else {
            if (Server::$config['broadcast_counts']) {
              // Notify clients of the subscription count.
              foreach ($curClients as $key) {
                $curData = $curClients[$key];
                if ($curData['count']) {
                  $key->send(json_encode([
                    'query' => $curData['query'],
                    'count' => $count
                  ]));
                }
              }
            }
          }
          $mess++;
        }
      }
      unset($curClients);
    }
    unset($curSubscriptions);

    foreach ($this->uidSubs as $curUID => $curClients) {
      if ($curClients->contains($conn)) {
        unset($curClients[$conn]);

        $count = count($curClients);

        if ($count === 0) {
          unset($this->uidSubs[$curUID]);
        } else {
          if (Server::$config['broadcast_counts']) {
            // Notify clients of the subscription count.
            foreach ($curClients as $key) {
              $curData = $curClients[$key];
              if ($curData['count']) {
                $key->send(json_encode([
                  'uid' => $curUID,
                  'count' => $count
                ]));
              }
            }
          }
        }
        $mess++;
      }
    }

    if ($this->sessions->contains($conn)) {
      unset($this->sessions[$conn]);
      $mess++;
    }

    if ($mess) {
      $this->logger->notice(
          "Cleaned up client's mess. ".
            "($mess, {$conn->resourceId})"
      );
    }
  }
1172742
public function freeConnection($connection) {
		$this->connection->push($connection);
		if ($this->wait->count() > 0) {
			$uid = $this->wait->pop();
			co::resume($uid);
		} else {
			//有连接处于空闲状态超过15秒，关闭一个连接
			if ($this->connection_count > $this->getMinClient() && time() - $this->last_run_out_time > 15) {
				$this->close();
			}
		}
	}
463706
public function rollback(ConnectionInterface $connection)
    {
        $connectionId = $connection->getName();

        if ($this->transactionLevel > 1) {
            array_pop($this->pendingEvents[$connectionId][$this->transactionLevel]);
        } else {
            unset($this->pendingEvents[$connectionId]);
        }

        $this->transactionLevel--;
    }
375138
public function addConnection(ConnectionInterface $connection)
    {
        // TODO: This should be a pool of connections


        if ($connection->isReadable()) {
            $this->readConnection = $connection;
        }

        if ($connection->isWritable()) {
            $this->writeConnection = $connection;
        }
    }
565485
public function reconnect($name)
    {
        if (isset($this->connections[$name])) {
            $this->disconnect($name);
            $this->usePdo($name);
        }
    }
323885
public function commit(ConnectionInterface $connection)
    {
        // We decrement the transaction level and prevent events to be dispatched
        // while comitting nested transactions, so no transient state is saved.
        // Only dispatch events right after the outer transaction commits.
        $this->transactionLevel--;
        if (! $this->isPrepared($connection) || $this->transactionLevel > 0) {
            return;
        }

        $this->dispatchPendingEvents($connection);
    }
999839
public function onOpen(ConnectionInterface $conn)
    {
        $this->conn = $conn;

        $this->attach()->throttle()->limit();
    }
1192689
protected function ensureConnectionIsEstablished($connection)
    {
        if (!$this->isConnectionEstablished($connection)) {
            $message = $this->createConnectionErrorMessage($connection);

            throw new ConnectionException($message);
        }
    }
950160
public function preDelete(ConnectionInterface $con = null)
    {
        parent::preDelete($con);

        if ($this->getIsDefault()) {
            return false;
        }

        $this->dispatchEvent(TheliaEvents::BEFORE_DELETEADDRESS, new AddressEvent($this));

        return true;
    }
367522
def release(self, connection):
        ""
        self._checkpid()
        if connection.pid != self.pid:
            return
        self._in_use_connections.remove(connection)
        # discard connection with unread response
        if connection.awaiting_response:
            connection.disconnect()
            self._created_connections -= 1
        else:
            self._available_connections.append(connection)
525773
public function updateSkillCount(ConnectionInterface $con)
    {
        $this->setSkillCount($this->computeSkillCount($con));
        $this->save($con);
    }
205466
public function onConnect(Connection $conn)
    {
        // 加入新连接重新调整所有连接rdy状态
        $conn->setDelegate($this);
        $conn->writeCmd(Command::subscribe($this->topic, $this->channel));
        $this->maybeUpdateRDY($conn);
    }
1131929
public static function release($db)
    {
        $resource = RequestContext::get('poolResources.' . spl_object_hash($db));
        if(null !== $resource)
        {
            PoolManager::releaseResource($resource);
        }
    }