mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
fix: potential endless loop under extremely high load
If there are more connections waiting to be accepted than MAX_INCOMING_CONNECTIONS existing accepted connections are overwritten.
This commit is contained in:
parent
9fae455bab
commit
ad2375ffe9
|
@ -1 +1 @@
|
||||||
5cf49ad258527f6a2734a9d1f863084f66189338f47ca9d0a49482b4217577fb /usr/local/bin/tox-bootstrapd
|
2f7cc0e1acb07697f55fce064328e8193e54bd20189370b0c56c3b2264bdfa24 /usr/local/bin/tox-bootstrapd
|
||||||
|
|
|
@ -1033,12 +1033,15 @@ TCP_Server *new_TCP_server(const Logger *logger, const Random *rng, const Networ
|
||||||
non_null()
|
non_null()
|
||||||
static void do_TCP_accept_new(TCP_Server *tcp_server)
|
static void do_TCP_accept_new(TCP_Server *tcp_server)
|
||||||
{
|
{
|
||||||
for (uint32_t i = 0; i < tcp_server->num_listening_socks; ++i) {
|
for (uint32_t sock_idx = 0; sock_idx < tcp_server->num_listening_socks; ++sock_idx) {
|
||||||
Socket sock;
|
|
||||||
|
|
||||||
do {
|
for (uint32_t connection_idx = 0; connection_idx < MAX_INCOMING_CONNECTIONS; ++connection_idx) {
|
||||||
sock = net_accept(tcp_server->ns, tcp_server->socks_listening[i]);
|
const Socket sock = net_accept(tcp_server->ns, tcp_server->socks_listening[sock_idx]);
|
||||||
} while (accept_connection(tcp_server, sock) != -1);
|
|
||||||
|
if (accept_connection(tcp_server, sock) == -1) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue
Block a user