Skip to content

Commit 656845b

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 359b3a2 commit 656845b

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
@@ -29,6 +29,20 @@ MecAppBase::~MecAppBase()
2929
{
3030
cancelAndDelete(sendTimer);
3131

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

3448
cancelAndDelete(processMessage_);

0 commit comments

Comments
 (0)