message: optimize long connections
diff: @@ -859,21 +859,14 @@ swClient* php_swoole_client_new(zval *zobject, char *host, int host_len, int por
  if (type & SW_FLAG_KEEP)
  {
  auto i = long_connections.find(conn_key);
  - queue<swClient*> *q;
  - if (i == long_connections.end())
  + if (i == long_connections.end() || i->second->empty())
  {
  - q = new queue<swClient*>;
  - long_connections[conn_key] = q;
  - _alloc: cli = (swClient*) pemalloc(sizeof(swClient), 1);
  + cli = (swClient*) pemalloc(sizeof(swClient), 1);
  goto create_socket;
  }
  else
  {
  - q = i->second;
  - if (q->empty())
  - {
  - goto _alloc;
  - }
  + queue<swClient*> *q = i->second;
  cli = q->front();
  q->pop();
  //try recv, check connection status
  @@ -881,6 +874,8 @@ swClient* php_swoole_client_new(zval *zobject, char *host, int host_len, int por
  if (ret == 0 || (ret < 0 && swConnection_error(errno) == SW_CLOSE))
  {
  cli->close(cli);
  + php_swoole_client_free(zobject, cli);
  + cli = (swClient*) pemalloc(sizeof(swClient), 1);
  goto create_socket;
  }
  cli->reuse_count++;
  @@ -1697,11 +1692,19 @@ static PHP_METHOD(swoole_client, close)
  {
  if (cli->keep)
  {
  - auto i = long_connections.find(string(cli->server_str, cli->server_strlen));
  - if (i != long_connections.end())
  + string conn_key(cli->server_str, cli->server_strlen);
  + queue<swClient*> *q;
  + auto i = long_connections.find(conn_key);
  + if (i == long_connections.end())
  + {
  + q = new queue<swClient*>;
  + long_connections[conn_key] = q;
  + }
  + else
  {
  - i->second->push(cli);
  + q = i->second;
  }
  + q->push(cli);
  }
  //unset object
  swoole_set_object(getThis(), NULL);
  