Skip to content

Commit

Permalink
Added main thread sleep to realmd to decrease CPU usage and database …
Browse files Browse the repository at this point in the history
…keepalive spam
  • Loading branch information
namreeb committed Mar 21, 2016
1 parent fade6cf commit c902455
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/realmd/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
#include <boost/version.hpp>

#include <iostream>
#include <chrono>
#include <thread>

#ifdef WIN32
#include "ServiceWin32.h"
Expand Down Expand Up @@ -256,7 +258,7 @@ int main(int argc, char *argv[])
LoginDatabase.AllowAsyncTransactions();

// maximum counter for next ping
uint32 numLoops = (sConfig.GetIntDefault("MaxPingTime", 30) * (MINUTE * 1000000 / 100000));
auto const numLoops = sConfig.GetIntDefault("MaxPingTime", 30) * MINUTE * 10;
uint32 loopCounter = 0;

#ifndef WIN32
Expand All @@ -271,6 +273,7 @@ int main(int argc, char *argv[])
DETAIL_LOG("Ping MySQL to keep connection alive");
LoginDatabase.Ping();
}
std::this_thread::sleep_for(std::chrono::milliseconds(100));
#ifdef WIN32
if (m_ServiceStatus == 0) stopEvent = true;
while (m_ServiceStatus == 2) Sleep(1000);
Expand Down

2 comments on commit c902455

@Grz3s
Copy link
Member

@Grz3s Grz3s commented on c902455 Mar 21, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 thank you.

@Dramacydal
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thats cruel

Please sign in to comment.