summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaria Matejka <mq@ucw.cz>2023-05-08 18:57:32 +0200
committerMaria Matejka <mq@ucw.cz>2023-05-11 11:41:01 +0200
commit794f555f63cc662c73e9113fd1eff2ebba4e50ff (patch)
tree3ddea161c1d53037aaaf3d784226d816408824f2
parent2623b7ba5d2bc52640fe875fd8b02ec6c54cf7a2 (diff)
BGP: fix listen socket cleanup
-rw-r--r--proto/bgp/bgp.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/proto/bgp/bgp.c b/proto/bgp/bgp.c
index e2a0d7df..c98f84ab 100644
--- a/proto/bgp/bgp.c
+++ b/proto/bgp/bgp.c
@@ -197,13 +197,20 @@ bgp_close(struct bgp_proto *p)
struct bgp_listen_request *req = &p->listen;
struct bgp_socket *bs = req->sock;
- if (bs)
+ if (enlisted(&req->n))
{
- req->sock = NULL;
+ /* Remove listen request from listen socket or pending list */
rem_node(&req->n);
- if (bs && EMPTY_LIST(bs->requests))
- ev_send(&global_event_list, &bgp_listen_event);
+ if (bs)
+ {
+ /* Already had a socket. */
+ req->sock = NULL;
+
+ /* Request listen socket cleanup */
+ if (bs && EMPTY_LIST(bs->requests))
+ ev_send(&global_event_list, &bgp_listen_event);
+ }
}
UNLOCK_DOMAIN(rtable, bgp_listen_domain);