mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-12 02:19:41 +00:00
(svn r26046) -Fix: handle a number of failure conditions from methods called in the network code
This commit is contained in:
parent
b37d402b2d
commit
fad4fa09ba
@ -237,9 +237,9 @@ bool NetworkTCPSocketHandler::CanSendReceive()
|
||||
|
||||
tv.tv_sec = tv.tv_usec = 0; // don't block at all.
|
||||
#if !defined(__MORPHOS__) && !defined(__AMIGA__)
|
||||
select(FD_SETSIZE, &read_fd, &write_fd, NULL, &tv);
|
||||
if (select(FD_SETSIZE, &read_fd, &write_fd, NULL, &tv) < 0) return false;
|
||||
#else
|
||||
WaitSelect(FD_SETSIZE, &read_fd, &write_fd, NULL, &tv, NULL);
|
||||
if (WaitSelect(FD_SETSIZE, &read_fd, &write_fd, NULL, &tv, NULL) < 0) return false;
|
||||
#endif
|
||||
|
||||
this->writable = !!FD_ISSET(this->sock, &write_fd);
|
||||
|
@ -64,7 +64,9 @@ public:
|
||||
|
||||
DEBUG(net, 1, "[%s] Banned ip tried to join (%s), refused", Tsocket::GetName(), *iter);
|
||||
|
||||
send(s, (const char*)p.buffer, p.size, 0);
|
||||
if (send(s, (const char*)p.buffer, p.size, 0) < 0) {
|
||||
DEBUG(net, 0, "send failed with error %d", GET_LAST_ERROR());
|
||||
}
|
||||
closesocket(s);
|
||||
break;
|
||||
}
|
||||
@ -79,7 +81,9 @@ public:
|
||||
Packet p(Tfull_packet);
|
||||
p.PrepareToSend();
|
||||
|
||||
send(s, (const char*)p.buffer, p.size, 0);
|
||||
if (send(s, (const char*)p.buffer, p.size, 0) < 0) {
|
||||
DEBUG(net, 0, "send failed with error %d", GET_LAST_ERROR());
|
||||
}
|
||||
closesocket(s);
|
||||
|
||||
continue;
|
||||
@ -115,9 +119,9 @@ public:
|
||||
|
||||
tv.tv_sec = tv.tv_usec = 0; // don't block at all.
|
||||
#if !defined(__MORPHOS__) && !defined(__AMIGA__)
|
||||
select(FD_SETSIZE, &read_fd, &write_fd, NULL, &tv);
|
||||
if (select(FD_SETSIZE, &read_fd, &write_fd, NULL, &tv) < 0) return false;
|
||||
#else
|
||||
WaitSelect(FD_SETSIZE, &read_fd, &write_fd, NULL, &tv, NULL);
|
||||
if (WaitSelect(FD_SETSIZE, &read_fd, &write_fd, NULL, &tv, NULL) < 0) return false;
|
||||
#endif
|
||||
|
||||
/* accept clients.. */
|
||||
|
@ -96,7 +96,9 @@ void NetworkUDPSocketHandler::SendPacket(Packet *p, NetworkAddress *recv, bool a
|
||||
if (broadcast) {
|
||||
/* Enable broadcast */
|
||||
unsigned long val = 1;
|
||||
setsockopt(s->second, SOL_SOCKET, SO_BROADCAST, (char *) &val, sizeof(val));
|
||||
if (setsockopt(s->second, SOL_SOCKET, SO_BROADCAST, (char *) &val, sizeof(val)) < 0) {
|
||||
DEBUG(net, 1, "[udp] setting broadcast failed with: %i", GET_LAST_ERROR());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user