mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2026-04-14 03:36:38 +00:00
fixed debug output, server exit hang, crashes
This commit is contained in:
@@ -230,7 +230,7 @@ void TCPServerMain(){
|
||||
if (bind(Listener, (sockaddr*)&addr, sizeof(addr)) == SOCKET_ERROR){
|
||||
error(Sec("Can't bind socket! ") + std::to_string(WSAGetLastError()));
|
||||
std::this_thread::sleep_for(std::chrono::seconds(5));
|
||||
exit(-1);
|
||||
_Exit(-1);
|
||||
}
|
||||
if(Listener == -1){
|
||||
error(Sec("Invalid listening socket"));
|
||||
@@ -264,7 +264,7 @@ void TCPServerMain(){
|
||||
if (bind(Listener, (sockaddr*)&addr, sizeof(addr)) != 0){
|
||||
error(Sec("Can't bind socket! ") + std::string(strerror(errno)));
|
||||
std::this_thread::sleep_for(std::chrono::seconds(5));
|
||||
exit(-1);
|
||||
_Exit(-1);
|
||||
}
|
||||
if(Listener == -1){
|
||||
error(Sec("Invalid listening socket"));
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "Network.h"
|
||||
#include "Logger.h"
|
||||
#include "UnixCompat.h"
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
|
||||
|
||||
@@ -47,7 +48,7 @@ void VehicleParser(Client*c,const std::string& Pckt){
|
||||
Packet = "Os:"+c->GetRole()+":"+c->GetName()+":"+std::to_string(c->GetID())+"-"+std::to_string(CarID)+Packet.substr(4);
|
||||
if(c->GetCarCount() >= MaxCars ||
|
||||
TriggerLuaEvent(Sec("onVehicleSpawn"),false,nullptr,
|
||||
std::unique_ptr<LuaArg>(new LuaArg{{c->GetID(),CarID,Packet.substr(3)}}),
|
||||
std::make_unique<LuaArg>(LuaArg{{c->GetID(),CarID,Packet.substr(3)}}),
|
||||
true)){
|
||||
Respond(c,Packet,true);
|
||||
std::string Destroy = "Od:" + std::to_string(c->GetID())+"-"+std::to_string(CarID);
|
||||
|
||||
@@ -35,7 +35,7 @@ std::string PostHTTP(const std::string& IP,const std::string& Fields){
|
||||
Assert(curl);
|
||||
if(curl) {
|
||||
curl_easy_setopt(curl, CURLOPT_URL, IP.c_str());
|
||||
/*curl_easy_setopt(curl, CURLOPT_URL, "95.216.35.232/heartbeatv2");
|
||||
/*curl_easy_setopt(curl, CURLOPT_URL, "https://95.216.35.232/heartbeatv2");
|
||||
curl_easy_setopt(curl, CURLOPT_PORT, 3600);*/
|
||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, Fields.size());
|
||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, Fields.c_str());
|
||||
|
||||
@@ -75,7 +75,6 @@ void OnDisconnect(Client*c,bool kicked){
|
||||
SendToAll(c, Packet,false,true);
|
||||
Packet.clear();
|
||||
TriggerLuaEvent(Sec("onPlayerDisconnect"),false,nullptr,std::unique_ptr<LuaArg>(new LuaArg{{c->GetID()}}),false);
|
||||
c->ClearCars();
|
||||
CI->RemoveClient(c); ///Removes the Client from existence
|
||||
}
|
||||
void OnConnect(Client*c){
|
||||
|
||||
@@ -269,18 +269,20 @@ void UDPParser(Client* c, std::string Packet) {
|
||||
void LOOP() {
|
||||
DebugPrintTID();
|
||||
while (UDPSock != -1) {
|
||||
for (PacketData* p : DataAcks) {
|
||||
if (p != nullptr) {
|
||||
if (p->Client == nullptr || p->Client->GetTCPSock() == -1) {
|
||||
DataAcks.erase(p);
|
||||
break;
|
||||
}
|
||||
if (p->Tries < 15) {
|
||||
UDPSend(p->Client, p->Data);
|
||||
p->Tries++;
|
||||
} else {
|
||||
DataAcks.erase(p);
|
||||
break;
|
||||
if(!DataAcks.empty()) {
|
||||
for (PacketData *p : DataAcks) {
|
||||
if (p != nullptr) {
|
||||
if (p->Client == nullptr || p->Client->GetTCPSock() == -1) {
|
||||
DataAcks.erase(p);
|
||||
break;
|
||||
}
|
||||
if (p->Tries < 15) {
|
||||
UDPSend(p->Client, p->Data);
|
||||
p->Tries++;
|
||||
} else {
|
||||
DataAcks.erase(p);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -306,7 +308,7 @@ void LOOP() {
|
||||
if (bind(UDPSock, (sockaddr*)&serverAddr, sizeof(serverAddr)) == SOCKET_ERROR) {
|
||||
error(Sec("Can't bind socket!") + std::to_string(WSAGetLastError()));
|
||||
std::this_thread::sleep_for(std::chrono::seconds(5));
|
||||
exit(-1);
|
||||
_Exit(-1);
|
||||
//return;
|
||||
}
|
||||
|
||||
@@ -348,7 +350,7 @@ void LOOP() {
|
||||
if (bind(UDPSock, (sockaddr*)&serverAddr, sizeof(serverAddr)) != 0) {
|
||||
error(Sec("Can't bind socket!") + std::string(strerror(errno)));
|
||||
std::this_thread::sleep_for(std::chrono::seconds(5));
|
||||
exit(-1);
|
||||
_Exit(-1);
|
||||
//return;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ void SyncData(){
|
||||
}catch(std::exception const& e){
|
||||
error(e.what());
|
||||
std::this_thread::sleep_for(std::chrono::seconds(3));
|
||||
exit(0);
|
||||
_Exit(0);
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user