dont SIGPIPE on broken pipe send()

This commit is contained in:
Lion Kortlepel 2021-03-30 15:04:53 +02:00
parent 2c06a98e00
commit eaa6b5322f

View File

@ -359,12 +359,14 @@ bool TNetwork::TCPSend(TClient& c, const std::string& Data, bool IsSync) {
Sent = 0;
Size += 4;
do {
int32_t Temp = send(c.GetTCPSock(), &Send[Sent], Size - Sent, 0);
int32_t Temp = send(c.GetTCPSock(), &Send[Sent], Size - Sent, MSG_NOSIGNAL);
if (Temp == 0) {
debug("send() == 0: " + std::string(std::strerror(errno)));
if (c.GetStatus() > -1)
c.SetStatus(-1);
return false;
} else if (Temp < 0) {
debug("send() < 0: " + std::string(std::strerror(errno)));
if (c.GetStatus() > -1)
c.SetStatus(-1);
CloseSocketProper(c.GetTCPSock());