diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-07-19 20:26:11 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-07-19 20:26:11 +0300 |
commit | c5400b010783f5e695569163b0ad42afb123b4f8 (patch) | |
tree | 9f558a1f80b20562017e8ee081b6d854af8c71b5 /src | |
parent | eff2fe4be9a25e6f870967d1a5e492c05f6b0abd (diff) | |
download | plus-c5400b010783f5e695569163b0ad42afb123b4f8.tar.gz plus-c5400b010783f5e695569163b0ad42afb123b4f8.tar.bz2 plus-c5400b010783f5e695569163b0ad42afb123b4f8.tar.xz plus-c5400b010783f5e695569163b0ad42afb123b4f8.zip |
Fix memory leak in ipc on client exit.
Diffstat (limited to 'src')
-rw-r--r-- | src/client.cpp | 3 | ||||
-rw-r--r-- | src/net/ipc.cpp | 17 |
2 files changed, 16 insertions, 4 deletions
diff --git a/src/client.cpp b/src/client.cpp index 36dd0536c..e620b0a51 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -83,6 +83,7 @@ #include "net/generalhandler.h" #include "net/guildhandler.h" #include "net/inventoryhandler.h" +#include "net/ipc.h" #include "net/loginhandler.h" #include "net/net.h" #include "net/netconsts.h" @@ -624,6 +625,8 @@ void Client::gameClear() if (Net::getChatHandler()) Net::getChatHandler()->clear(); + delete2(ipc); + #ifdef USE_MUMBLE delete2(mumbleManager); #endif diff --git a/src/net/ipc.cpp b/src/net/ipc.cpp index 6d7c2c45b..0c6b36a3b 100644 --- a/src/net/ipc.cpp +++ b/src/net/ipc.cpp @@ -47,6 +47,16 @@ IPC::IPC() : IPC::~IPC() { + mListen = false; + if (mSocket) + { + TcpNet::closeSocket(mSocket); + mSocket = nullptr; + } + int status; + if (mThread && SDL_GetThreadID(mThread)) + SDL_WaitThread(mThread, &status); + mThread = nullptr; } bool IPC::init() @@ -127,6 +137,8 @@ int IPC::acceptLoop(void *ptr) TcpNet::closeSocket(sock); } TcpNet::closeSocket(ipc1->mSocket); + ipc1->mSocket = nullptr; + ipc->mThread = nullptr; return 0; } @@ -136,10 +148,7 @@ void IPC::stop() return; logger->log("Stopping IPC..."); - ipc->mListen = false; - int loopRet; - SDL_WaitThread(ipc->mThread, &loopRet); - ipc = nullptr; + delete2(ipc); } void IPC::start() |