Пример #1
0
static void connection_free(ConnectionPtr conn) {
	if (conn) {
		log_info("Closing connection %d", conn->socket);
		if (conn->destroy) {
			log_debug("Calling destroy callback before closing connection");
			conn->destroy(conn->destroyarg, conn);
		}
		close(conn->socket);
		if (conn->server && conn->server->dispatch) {
			dispatch_remove_fd(conn->server->dispatch, conn->socket);
		}
		free(conn->buffer);
		free(conn);
	}
}
Пример #2
0
/*!
  Delete a connection.
 */
int Server::deleteConnection (ConnectionPtr s)
{
  notifyDeleteConnection (s);
  connectionsScheduler.removeConnection (s);

  s->destroy ();

  connectionsPoolLock.lock ();
  try
    {
      connectionsPool.put (s);
      connectionsPoolLock.unlock ();
    }
  catch (...)
    {
      connectionsPoolLock.unlock ();
      throw;
    }

  return 0;
}