game: suppress repeated close-phase send noise
Some checks failed
build / Linux asan (push) Has been cancelled
build / Linux release (push) Has been cancelled
build / FreeBSD build (push) Has been cancelled

This commit is contained in:
server
2026-04-14 16:30:08 +02:00
parent f702a64305
commit e306c7c500
2 changed files with 36 additions and 1 deletions

View File

@@ -17,6 +17,18 @@
#include "locale_service.h" #include "locale_service.h"
#include "log.h" #include "log.h"
namespace
{
bool IsPeerDisconnectWriteError(int error_code)
{
#ifdef OS_WINDOWS
return error_code == WSAECONNRESET || error_code == WSAECONNABORTED || error_code == WSAENOTCONN;
#else
return error_code == EPIPE || error_code == ECONNRESET || error_code == ENOTCONN;
#endif
}
}
extern int max_bytes_written; extern int max_bytes_written;
extern int current_bytes_written; extern int current_bytes_written;
extern int total_bytes_written; extern int total_bytes_written;
@@ -318,7 +330,14 @@ int DESC::ProcessOutput()
} }
#endif #endif
sys_err("ProcessOutput: send failed: %s (fd %d)", strerror(errno), m_sock); const int error_code = errno;
BeginClosePhase();
if (IsPeerDisconnectWriteError(error_code))
sys_log(0, "ProcessOutput: peer disconnected during send (host=%s fd=%d errno=%d %s)", GetHostName(), m_sock, error_code, strerror(error_code));
else
sys_err("ProcessOutput: send failed (host=%s fd=%d errno=%d %s)", GetHostName(), m_sock, error_code, strerror(error_code));
return -1; return -1;
} }
@@ -408,8 +427,23 @@ void DESC::LargePacket(const void * c_pvData, int iSize)
Packet(c_pvData, iSize); Packet(c_pvData, iSize);
} }
void DESC::BeginClosePhase()
{
if (m_iPhase == PHASE_CLOSE)
return;
m_iPhase = PHASE_CLOSE;
m_pInputProcessor = &m_inputClose;
}
void DESC::SetPhase(int _phase) void DESC::SetPhase(int _phase)
{ {
if (_phase == PHASE_CLOSE)
{
BeginClosePhase();
return;
}
m_iPhase = _phase; m_iPhase = _phase;
TPacketGCPhase pack; TPacketGCPhase pack;

View File

@@ -146,6 +146,7 @@ class DESC
protected: protected:
void Initialize(); void Initialize();
void BeginClosePhase();
protected: protected:
CInputProcessor * m_pInputProcessor; CInputProcessor * m_pInputProcessor;