mirror of
https://github.com/SantaSpeen/BeamMP-Server.git
synced 2026-02-16 13:30:40 +00:00
Print TIDs in every new thread
This commit is contained in:
@@ -5,8 +5,8 @@
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
void InitLog();
|
||||
#define DebugPrintTID(what) DebugPrintTIDInternal(what, __func__)
|
||||
void DebugPrintTIDInternal(const std::string& what, const std::string& func); // prints the current thread id in debug mode, to make tracing of crashes and asserts easier
|
||||
#define DebugPrintTID() DebugPrintTIDInternal(__func__)
|
||||
void DebugPrintTIDInternal(const std::string& func); // prints the current thread id in debug mode, to make tracing of crashes and asserts easier
|
||||
void ConsoleOut(const std::string& msg);
|
||||
void QueueAbort();
|
||||
void except(const std::string& toPrint);
|
||||
|
||||
@@ -47,6 +47,7 @@ void ConsoleOut(const std::string& msg){
|
||||
}
|
||||
|
||||
[[noreturn]] void OutputRefresh(){
|
||||
DebugPrintTID();
|
||||
while(true){
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||||
ProcessOut();
|
||||
@@ -104,6 +105,7 @@ void SetupConsole(){
|
||||
}
|
||||
|
||||
[[noreturn]] void ReadCin(){
|
||||
DebugPrintTID();
|
||||
while (true){
|
||||
int In = _getch();
|
||||
if (In == 13 || In == '\n') {
|
||||
|
||||
@@ -29,6 +29,7 @@ std::string GenerateCall(){
|
||||
return ret;
|
||||
}
|
||||
void Heartbeat(){
|
||||
DebugPrintTID();
|
||||
std::string R,T;
|
||||
while(true){
|
||||
R = GenerateCall();
|
||||
@@ -56,4 +57,4 @@ void Heartbeat(){
|
||||
void HBInit(){
|
||||
std::thread HB(Heartbeat);
|
||||
HB.detach();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ void FolderList(const std::string& Path,bool HotSwap){
|
||||
}
|
||||
}
|
||||
[[noreturn]]void HotSwaps(const std::string& path){
|
||||
DebugPrintTID();
|
||||
while(true){
|
||||
for(Lua*Script : PluginEngine){
|
||||
struct stat Info{};
|
||||
|
||||
@@ -162,6 +162,7 @@ void ExecuteAsync(Lua* lua,const std::string& FuncName){
|
||||
SafeExecution(lua,FuncName);
|
||||
}
|
||||
void CallAsync(Lua* lua,const std::string& Func,int U){
|
||||
DebugPrintTID();
|
||||
lua->StopThread = false;
|
||||
int D = 1000 / U;
|
||||
while(!lua->StopThread){
|
||||
|
||||
@@ -178,6 +178,7 @@ void Identify(SOCKET TCPSock){
|
||||
}
|
||||
|
||||
void TCPServerMain(){
|
||||
DebugPrintTID();
|
||||
#ifdef __WIN32
|
||||
WSADATA wsaData;
|
||||
if (WSAStartup(514, &wsaData)){
|
||||
|
||||
@@ -30,6 +30,7 @@ void Monitor() {
|
||||
}
|
||||
|
||||
[[noreturn]]void Stat(){
|
||||
DebugPrintTID();
|
||||
while(true){
|
||||
Monitor();
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
|
||||
@@ -56,6 +56,7 @@ void TCPRcv(Client*c){
|
||||
TCPHandle(c,Buf);
|
||||
}
|
||||
void TCPClient(Client*c){
|
||||
DebugPrintTID();
|
||||
Assert(c);
|
||||
if(c->GetTCPSock() == -1){
|
||||
CI->RemoveClient(c);
|
||||
|
||||
@@ -245,6 +245,7 @@ void UDPParser(Client* c, std::string Packet) {
|
||||
GParser(c, Packet);
|
||||
}
|
||||
void LOOP() {
|
||||
DebugPrintTID();
|
||||
while (UDPSock != -1) {
|
||||
for (PacketData* p : DataAcks) {
|
||||
if (p != nullptr) {
|
||||
|
||||
@@ -10,11 +10,11 @@
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
|
||||
void DebugPrintTIDInternal(const std::string& what, const std::string& func) {
|
||||
void DebugPrintTIDInternal(const std::string& func) {
|
||||
// we need to print to cout here as we might crash before all console output is handled,
|
||||
// due to segfaults or asserts.
|
||||
#ifdef DEBUG
|
||||
std::cout << "(debug build) Thread '" << std::this_thread::get_id() << "' in " << func << " is " << what << std::endl;
|
||||
std::cout << "(debug build) Thread '" << std::this_thread::get_id() << "' is " << func << std::endl;
|
||||
#endif // DEBUG
|
||||
}
|
||||
|
||||
|
||||
@@ -3,20 +3,18 @@
|
||||
#include <thread>
|
||||
#include <iostream>
|
||||
[[noreturn]] void loop(){
|
||||
DebugPrintTID("test loop");
|
||||
DebugPrintTID();
|
||||
while(true){
|
||||
std::cout.flush();
|
||||
Assert(false);
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(600));
|
||||
}
|
||||
}
|
||||
int main(int argc, char* argv[]) {
|
||||
DebugPrintTID("main");
|
||||
DebugPrintTID();
|
||||
#ifdef DEBUG
|
||||
std::thread t1(loop);
|
||||
t1.detach();
|
||||
#endif
|
||||
Assert(false);
|
||||
ConsoleInit();
|
||||
InitServer(argc,argv);
|
||||
InitConfig();
|
||||
|
||||
Reference in New Issue
Block a user