From 571c4f69bfbcf437d848b332bb2f4995fea2347d Mon Sep 17 00:00:00 2001 From: Maria Matejka Date: Fri, 24 Feb 2023 09:13:35 +0100 Subject: More efficient IO loop event execution to avoid long loops If there are lots of loops in a single thread and only some of the loops are actually active, the other loops are now kept aside and not checked until they actually get some timers, events or active sockets. This should help with extreme loads like 100k tables and protocols. Also ping and loop pickup mechanism was allowing subtle race conditions. Now properly handling collisions between loop ping and pickup. --- proto/bgp/bgp.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'proto/bgp/bgp.c') diff --git a/proto/bgp/bgp.c b/proto/bgp/bgp.c index cca1283c..122b0c22 100644 --- a/proto/bgp/bgp.c +++ b/proto/bgp/bgp.c @@ -217,6 +217,8 @@ bgp_open(struct bgp_proto *p) req->port = p->cf->local_port; req->flags = p->cf->free_bind ? SKF_FREEBIND : 0; + BGP_TRACE(D_EVENTS, "Requesting listen socket at %I%J port %u", req->addr, req->iface, req->port); + add_tail(&bgp_listen_pending, &req->n); ev_schedule(&bgp_listen_event); } @@ -243,7 +245,9 @@ bgp_listen_create(void *_ UNUSED) break; /* Not found any */ - if (!NODE_VALID(bs)) + if (NODE_VALID(bs)) + BGP_TRACE(D_EVENTS, "Found a listening socket: %p", bs); + else { sock *sk = sk_new(proto_pool); sk->type = SK_TCP_PASSIVE; @@ -275,6 +279,8 @@ bgp_listen_create(void *_ UNUSED) init_list(&bs->requests); add_tail(&bgp_sockets, &bs->n); + + BGP_TRACE(D_EVENTS, "Created new listening socket: %p", bs); } add_tail(&bs->requests, &req->n); -- cgit v1.2.3