Skip to content

Commit

Permalink
https://telecominfraproject.atlassian.net/browse/WIFI-13147
Browse files Browse the repository at this point in the history
Signed-off-by: stephb9959 <[email protected]>
  • Loading branch information
stephb9959 committed Nov 23, 2023
1 parent 6cfb0ae commit 8581048
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/AP_WS_Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,15 @@ namespace OpenWifi {
std::lock_guard Lock(SerialNumbersMutex_[hashIndex]);
auto hint = SerialNumbers_[hashIndex].begin();
while (hint != end(SerialNumbers_[hashIndex])) {
std::cout << __LINE__ << std::endl;
if (hint->second.second == nullptr) {
hint = SerialNumbers_[hashIndex].erase(hint);
std::cout << __LINE__ << std::endl;
} else if ((now - hint->second.second->State_.LastContact) >
SessionTimeOut_) {
std::cout << __LINE__ << std::endl;
hint->second.second->EndConnection(false);
std::cout << __LINE__ << std::endl;
poco_information(
Logger(),
fmt::format(
Expand All @@ -209,41 +213,51 @@ namespace OpenWifi {
SessionsToRemove.emplace_back(hint->second.first);
Garbage_.push_back(hint->second.second);
hint = SerialNumbers_[hashIndex].erase(hint);
std::cout << __LINE__ << std::endl;
} else if (hint->second.second->State_.Connected) {
NumberOfConnectedDevices_++;
total_connected_time += (now - hint->second.second->State_.started);
hint++;
std::cout << __LINE__ << std::endl;
} else {
NumberOfConnectingDevices_++;
hint++;
std::cout << __LINE__ << std::endl;
}
}
}

std::cout << __LINE__ << std::endl;
if(SessionsToRemove.empty()) {
std::cout << __LINE__ << std::endl;
poco_information(Logger(), fmt::format("Removing {} sessions.", SessionsToRemove.size()));
std::lock_guard L1(WSServerMutex_);
for (const auto &Session : SessionsToRemove) {
Sessions_.erase(Session);
}
std::cout << __LINE__ << std::endl;
}

std::cout << __LINE__ << std::endl;
AverageDeviceConnectionTime_ =
NumberOfConnectedDevices_ > 0 ? total_connected_time / NumberOfConnectedDevices_
: 0;
NumberOfConnectedDevices_ > 0 ? total_connected_time / NumberOfConnectedDevices_
: 0;

poco_information(Logger(), fmt::format("Garbage collecting done..."));
} else {
NumberOfConnectedDevices_ = SerialNumbers_.size();
std::cout << __LINE__ << std::endl;
AverageDeviceConnectionTime_ += 10;
}

DBGLINE;
if ((now - last_log) > 120) {
last_log = now;
poco_information(Logger(),
fmt::format("Active AP connections: {} Connecting: {} Average connection time: {} seconds",
NumberOfConnectedDevices_, NumberOfConnectingDevices_,
AverageDeviceConnectionTime_));
}
DBGLINE;
}

GWWebSocketNotifications::NumberOfConnection_t Notification;
Expand Down

0 comments on commit 8581048

Please sign in to comment.