Fixing implicit memory leaks.
This commit is contained in:
@@ -42,6 +42,13 @@ ServerManager::ServerManager(GuiInterface &gui, ConfigFile &config, AvatarManage
|
|||||||
|
|
||||||
ServerManager::~ServerManager()
|
ServerManager::~ServerManager()
|
||||||
{
|
{
|
||||||
|
size_t remainingHandler = 0;
|
||||||
|
// Call all pending handlers to clean up.
|
||||||
|
do {
|
||||||
|
m_ioService->reset();
|
||||||
|
remainingHandler = m_ioService->poll();
|
||||||
|
} while (remainingHandler > 0);
|
||||||
|
m_ioService->reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -30,7 +30,6 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <memory>
|
|
||||||
#include <csignal>
|
#include <csignal>
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
@@ -78,7 +77,7 @@ main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
ENABLE_LEAK_CHECK();
|
ENABLE_LEAK_CHECK();
|
||||||
|
|
||||||
// _CrtSetBreakAlloc(4772);
|
//_CrtSetBreakAlloc(10260);
|
||||||
|
|
||||||
bool readonlyConfig = false;
|
bool readonlyConfig = false;
|
||||||
string pidFile;
|
string pidFile;
|
||||||
@@ -120,9 +119,9 @@ main(int argc, char *argv[])
|
|||||||
readonlyConfig = true;
|
readonlyConfig = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto_ptr<QtToolsInterface> myQtToolsInterface(CreateQtToolsWrapper());
|
boost::shared_ptr<QtToolsInterface> myQtToolsInterface(CreateQtToolsWrapper());
|
||||||
//create defaultconfig
|
//create defaultconfig
|
||||||
ConfigFile *myConfig = new ConfigFile(argv[0], readonlyConfig);
|
boost::shared_ptr<ConfigFile> myConfig(new ConfigFile(argv[0], readonlyConfig));
|
||||||
loghelper_init(myQtToolsInterface->stringFromUtf8(myConfig->readConfigString("LogDir")), logLevel);
|
loghelper_init(myQtToolsInterface->stringFromUtf8(myConfig->readConfigString("LogDir")), logLevel);
|
||||||
|
|
||||||
// TODO: Hack
|
// TODO: Hack
|
||||||
@@ -156,8 +155,8 @@ main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create pseudo Gui Wrapper for the server.
|
// Create pseudo Gui Wrapper for the server.
|
||||||
boost::shared_ptr<GuiInterface> myServerGuiInterface(new ServerGuiWrapper(myConfig, NULL, NULL, NULL));
|
boost::shared_ptr<GuiInterface> myServerGuiInterface(new ServerGuiWrapper(myConfig.get(), NULL, NULL, NULL));
|
||||||
boost::shared_ptr<Session> session(new Session(myServerGuiInterface.get(), myConfig));
|
boost::shared_ptr<Session> session(new Session(myServerGuiInterface.get(), myConfig.get()));
|
||||||
if (!session->init())
|
if (!session->init())
|
||||||
LOG_ERROR("Missing files - please check your directory settings!");
|
LOG_ERROR("Missing files - please check your directory settings!");
|
||||||
myServerGuiInterface->setSession(session);
|
myServerGuiInterface->setSession(session);
|
||||||
@@ -169,6 +168,9 @@ main(int argc, char *argv[])
|
|||||||
g_pokerthTerminate = true;
|
g_pokerthTerminate = true;
|
||||||
}
|
}
|
||||||
myServerGuiInterface->getSession()->terminateNetworkServer();
|
myServerGuiInterface->getSession()->terminateNetworkServer();
|
||||||
|
session.reset();
|
||||||
|
myServerGuiInterface.reset();
|
||||||
|
myConfig.reset();
|
||||||
|
|
||||||
LOG_MSG("Terminating PokerTH dedicated server." << endl);
|
LOG_MSG("Terminating PokerTH dedicated server." << endl);
|
||||||
socket_cleanup();
|
socket_cleanup();
|
||||||
|
|||||||
Reference in New Issue
Block a user