void ConnectionManager::addConnection(ConnectionPtr connectionPtr){ LOG_DEBUG("ConnectionManager::addConnection => begin : cid = %d" , connectionPtr->getId()); int poolIndex = getPoolIndex(connectionPtr->getId()); WriteLock lock(connectionPoolMutexs_[poolIndex]); connectionPools_[poolIndex][connectionPtr->getId()] = connectionPtr; }
void AsioServer::handleAccept(const boost::system::error_code& e){ LOG_DEBUG("AsioServer::handleAccept => accept a connection"); ConnectionPtr acceptConnection = newConnection_; newConnection_ = newConnection(); acceptor_.async_accept(newConnection_->getSocket(), boost::bind(&AsioServer::handleAccept, this, boost::asio::placeholders::error)); LOG_DEBUG("AsioServer::handleAccept => wait a new connection : cid = %d" , newConnection_->getId()); if(!e){ try{ acceptConnection->open(); LOG_DEBUG("AsioServer::handleAccept => new connection start : cid = %d" , acceptConnection->getId()); } catch (exception &e){ LOG_ERROR("AsioServer::handleAccept => new connection start error : what = %s" , e.what()); } } else { LOG_ERROR("AsioServer::handleAccept => error : " , e.message().c_str()); } }