1.Update the submodule trantor;

2.Optimize the logic of connection counting;
This commit is contained in:
antao 2019-01-31 14:12:01 +08:00
parent 715affad08
commit 1746e36eb4
4 changed files with 14 additions and 7 deletions

View File

@ -425,10 +425,16 @@ void HttpAppFrameworkImpl::onConnection(const TcpConnectionPtr &conn)
}
else
{
if (_connectionNum-- == 0)
#if (CXX_STD > 14)
if (!conn->getContext().has_value())
#else
if (conn->getContext().empty())
#endif
{
_connectionNum++;
//If the connection is connected to the SSL port and then disconnected before the SSL handshake.
return;
}
_connectionNum--;
if (_maxConnectionNumPerIP > 0)
{
std::lock_guard<std::mutex> lock(mtx);

View File

@ -174,12 +174,12 @@ class HttpAppFrameworkImpl : public HttpAppFramework
std::string _sslCertPath;
std::string _sslKeyPath;
size_t _maxConnectionNum = 100000;
size_t _maxConnectionNumPerIP = 0;
std::atomic<uint64_t> _connectionNum;
std::unordered_map<std::string, size_t> _connectionsNumMap;
int64_t _maxConnectionNum = 100000;
std::atomic<int64_t> _connectionNum;
bool _runAsDaemon = false;
bool _relaunchOnError = false;
std::string _logPath = "";

View File

@ -77,10 +77,12 @@ void HttpServer::onConnection(const TcpConnectionPtr &conn)
if (conn->connected())
{
conn->setContext(HttpRequestParser(conn));
_connectionCallback(conn);
}
else if (conn->disconnected())
{
LOG_TRACE << "conn disconnected!";
_connectionCallback(conn);
HttpRequestParser *requestParser = any_cast<HttpRequestParser>(conn->getMutableContext());
if (requestParser)
{
@ -95,7 +97,6 @@ void HttpServer::onConnection(const TcpConnectionPtr &conn)
#endif
}
}
_connectionCallback(conn);
}
void HttpServer::onMessage(const TcpConnectionPtr &conn,

@ -1 +1 @@
Subproject commit 947e415cf2fa71f2af0c2220a86d594b1732d26e
Subproject commit 04d22d2974db2295bd441d74623ae35eecb8dd6a