Skip to content

Commit 6ebf81b

Browse files
committed
MecAppBase: Eliminate undisposed objects
The ~MecAppBase() destructor in MecAppBase.cc:28 was calling sockets_.deleteSockets() which deletes the TcpSocket objects but does not clean up the HttpMessageStatus structs attached as userData to each socket. This mirrors the cleanup logic already present in removeSocket(), which was never called during destruction.
1 parent 9311c89 commit 6ebf81b

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

src/simu5g/apps/mec/MecApps/MecAppBase.cc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,20 @@ MecAppBase::~MecAppBase()
3030
std::cout << "MecAppBase::~MecAppBase()" << std::endl;
3131
cancelAndDelete(sendTimer);
3232

33+
for (auto &entry : sockets_.getMap()) {
34+
auto *sock = dynamic_cast<inet::TcpSocket *>(entry.second);
35+
if (sock == nullptr)
36+
continue;
37+
auto *msgStatus = static_cast<HttpMessageStatus *>(sock->getUserData());
38+
if (msgStatus == nullptr)
39+
continue;
40+
while (!msgStatus->httpMessageQueue.isEmpty())
41+
delete msgStatus->httpMessageQueue.pop();
42+
delete msgStatus->currentMessage;
43+
cancelAndDelete(msgStatus->processMsgTimer);
44+
delete msgStatus;
45+
sock->setUserData(nullptr);
46+
}
3347
sockets_.deleteSockets();
3448

3549
cancelAndDelete(processMessage_);

0 commit comments

Comments
 (0)