Compare commits

..

7 Commits

Author SHA1 Message Date
Lion Kortlepel 573bd77bbd v2.0.3 2021-04-06 12:50:39 +02:00
Lion Kortlepel 770e03e3c6 update lionkor/commandline to include build speedup 2021-04-06 11:25:16 +02:00
Lion Kortlepel 11d4522dc7 update lionkor/commandline to fix windows build 2021-04-05 23:27:32 +02:00
Lion Kortlepel 830bc47987 update lionkor/commandline
Fixes the 100% CPU spin issue when stdin was /dev/null or similar.
Thanks to @Worty for implementing this fix
2021-04-05 14:47:26 +02:00
Lion Kortlepel bec698fbdc temporary fix for timeout during sync 2021-04-04 02:57:25 +02:00
Lion Kortlepel 60cc835daf remove random 2 second sleep on every car sync (!) 2021-04-04 02:26:51 +02:00
Lion Kortlepel a85ce18589 Implement possible ghost player fix
coauthor @Anonymous-275
2021-04-04 01:44:40 +02:00
5 changed files with 15 additions and 17 deletions
+1 -1
View File
@@ -42,7 +42,7 @@ public:
// Causes all threads to finish up and exit gracefull gracefully // Causes all threads to finish up and exit gracefull gracefully
static void GracefullyShutdown(); static void GracefullyShutdown();
static TConsole& Console() { return *mConsole; } static TConsole& Console() { return *mConsole; }
static std::string ServerVersion() { return "2.0.2"; } static std::string ServerVersion() { return "2.0.3"; }
static std::string ClientVersion() { return "2.0"; } static std::string ClientVersion() { return "2.0"; }
static std::string PPS() { return mPPS; } static std::string PPS() { return mPPS; }
static void SetPPS(std::string NewPPS) { mPPS = NewPPS; } static void SetPPS(std::string NewPPS) { mPPS = NewPPS; }
+1 -1
View File
@@ -44,6 +44,6 @@ private:
void OnDisconnect(const std::weak_ptr<TClient>& ClientPtr, bool kicked); void OnDisconnect(const std::weak_ptr<TClient>& ClientPtr, bool kicked);
void Parse(TClient& c, const std::string& Packet); void Parse(TClient& c, const std::string& Packet);
void SendFile(TClient& c, const std::string& Name); void SendFile(TClient& c, const std::string& Name);
static bool TCPSendRaw(SOCKET C, char* Data, int32_t Size); static bool TCPSendRaw(TClient& C, SOCKET socket, char* Data, int32_t Size);
static void SplitLoad(TClient& c, size_t Sent, size_t Size, bool D, const std::string& Name); static void SplitLoad(TClient& c, size_t Sent, size_t Size, bool D, const std::string& Name);
}; };
+8 -8
View File
@@ -390,8 +390,8 @@ bool TNetwork::TCPSend(TClient& c, const std::string& Data, bool IsSync) {
return false; return false;
} }
Sent += Temp; Sent += Temp;
c.UpdatePingTime();
} while (Sent < Size); } while (Sent < Size);
c.UpdatePingTime();
return true; return true;
} }
@@ -757,7 +757,7 @@ void TNetwork::SplitLoad(TClient& c, size_t Sent, size_t Size, bool D, const std
if (Diff > Split) { if (Diff > Split) {
f.seekg(Sent, std::ios_base::beg); f.seekg(Sent, std::ios_base::beg);
f.read(Data, Split); f.read(Data, Split);
if (!TCPSendRaw(TCPSock, Data, Split)) { if (!TCPSendRaw(c, TCPSock, Data, Split)) {
if (c.GetStatus() > -1) if (c.GetStatus() > -1)
c.SetStatus(-1); c.SetStatus(-1);
break; break;
@@ -766,7 +766,7 @@ void TNetwork::SplitLoad(TClient& c, size_t Sent, size_t Size, bool D, const std
} else { } else {
f.seekg(Sent, std::ios_base::beg); f.seekg(Sent, std::ios_base::beg);
f.read(Data, Diff); f.read(Data, Diff);
if (!TCPSendRaw(TCPSock, Data, int32_t(Diff))) { if (!TCPSendRaw(c, TCPSock, Data, int32_t(Diff))) {
if (c.GetStatus() > -1) if (c.GetStatus() > -1)
c.SetStatus(-1); c.SetStatus(-1);
break; break;
@@ -778,16 +778,17 @@ void TNetwork::SplitLoad(TClient& c, size_t Sent, size_t Size, bool D, const std
f.close(); f.close();
} }
bool TNetwork::TCPSendRaw(SOCKET C, char* Data, int32_t Size) { bool TNetwork::TCPSendRaw(TClient& C, SOCKET socket, char* Data, int32_t Size) {
intmax_t Sent = 0; intmax_t Sent = 0;
do { do {
intmax_t Temp = send(C, &Data[Sent], int(Size - Sent), 0); intmax_t Temp = send(socket, &Data[Sent], int(Size - Sent), 0);
if (Temp < 1) { if (Temp < 1) {
info("Socket Closed! " + std::to_string(C)); info("Socket Closed! " + std::to_string(socket));
CloseSocketProper(C); CloseSocketProper(socket);
return false; return false;
} }
Sent += Temp; Sent += Temp;
C.UpdatePingTime();
} while (Sent < Size); } while (Sent < Size);
return true; return true;
} }
@@ -854,7 +855,6 @@ bool TNetwork::SyncClient(const std::weak_ptr<TClient>& c) {
return false; return false;
} }
res = Respond(*LockedClient, v.Data(), true, true); res = Respond(*LockedClient, v.Data(), true, true);
std::this_thread::sleep_for(std::chrono::seconds(2));
} }
} }
+4 -6
View File
@@ -36,17 +36,15 @@ void TPPSMonitor::operator()() {
ReadLock Lock(mServer.GetClientMutex()); ReadLock Lock(mServer.GetClientMutex());
if (!ClientPtr.expired()) { if (!ClientPtr.expired()) {
c = ClientPtr.lock(); c = ClientPtr.lock();
} else return true; } else
return true;
} }
if (c->GetCarCount() > 0) { if (c->GetCarCount() > 0) {
C++; C++;
V += c->GetCarCount(); V += c->GetCarCount();
} }
if (!c->IsSynced() || c->IsSyncing()) {
c->UpdatePingTime();
}
// kick on "no ping" // kick on "no ping"
if (c->SecondsSinceLastPing() > 30 && c->IsSynced() && !c->IsSyncing()) { if (c->SecondsSinceLastPing() > (5 * 60)) {
debug("client " + std::string("(") + std::to_string(c->GetID()) + ")" + c->GetName() + " timing out: " + std::to_string(c->SecondsSinceLastPing()) + ", pps: " + Application::PPS()); debug("client " + std::string("(") + std::to_string(c->GetID()) + ")" + c->GetName() + " timing out: " + std::to_string(c->SecondsSinceLastPing()) + ", pps: " + Application::PPS());
TimedOutClients.push_back(c); TimedOutClients.push_back(c);
} }
@@ -54,7 +52,7 @@ void TPPSMonitor::operator()() {
return true; return true;
}); });
for (auto& ClientToKick : TimedOutClients) { for (auto& ClientToKick : TimedOutClients) {
Network().ClientKick(*ClientToKick, "Timeout (no ping for >30 seconds)"); Network().ClientKick(*ClientToKick, "Timeout (no ping for >5 min)");
} }
TimedOutClients.clear(); TimedOutClients.clear();
if (C == 0 || mInternalPPS == 0) { if (C == 0 || mInternalPPS == 0) {