mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-16 11:33:03 +01:00
Prevent SIGPIPE-ing on Linux when clients drop (#3755)
`send()` can only write to connected sockets [1]. In case where client drops out, a socket may become closed by OS but we can still enqueue packets for its connection and eventually call `send()`, which will generate a SIGPIPE and shut the server down, because there was no `MSG_NOSIGNAL` set. This commit makes sure `MSG_NOSIGNAL` is used on Linux. [1] http://linux.die.net/man/2/send
This commit is contained in:
committed by
Ted John
parent
91443d0e75
commit
40253a7add
@@ -428,7 +428,7 @@ bool NetworkConnection::SendPacket(NetworkPacket& packet)
|
||||
tosend.insert(tosend.end(), (uint8*)&sizen, (uint8*)&sizen + sizeof(sizen));
|
||||
tosend.insert(tosend.end(), packet.data->begin(), packet.data->end());
|
||||
while (1) {
|
||||
int sentBytes = send(socket, (const char*)&tosend[packet.transferred], tosend.size() - packet.transferred, 0);
|
||||
int sentBytes = send(socket, (const char*)&tosend[packet.transferred], tosend.size() - packet.transferred, FLAG_NO_PIPE);
|
||||
if (sentBytes == SOCKET_ERROR) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user