MCPcopy Create free account
hub / github.com/Pagghiu/SaneCppLibraries / activateNew

Method activateNew

Libraries/Http/HttpConnection.cpp:1414–1442  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1412}
1413
1414bool HttpConnectionsPool::activateNew(HttpConnection::ID& connectionID)
1415{
1416 for (size_t idx = 0; idx < connections.sizeInElements(); ++idx)
1417 {
1418 HttpConnection& connection = connections[idx];
1419 if (connection.state == HttpConnection::State::Inactive)
1420 {
1421 connection.state = HttpConnection::State::Active;
1422 connectionID.index = idx;
1423 connection.connectionID = connectionID;
1424
1425 if (idx > highestActiveConnection)
1426 {
1427 highestActiveConnection = idx;
1428 }
1429 connection.request.setHeaderMemory(connection.getHeaderMemory());
1430 connection.response.setHeaderMemory(connection.getHeaderMemory());
1431 numConnections++;
1432 if (numConnections == connections.sizeInElements())
1433 {
1434 // avoid deadlock by force disabling keep-alive if this is the last connection
1435 // TODO: Consider some criteria that will disable keep alive after a threshold of active connections
1436 connection.response.forceDisableKeepAlive = true;
1437 }
1438 return true;
1439 }
1440 }
1441 return false;
1442}
1443
1444bool HttpConnectionsPool::deactivate(HttpConnection::ID connectionID)
1445{

Callers 1

onNewClientMethod · 0.80

Calls 1

setHeaderMemoryMethod · 0.80

Tested by

no test coverage detected