diff options
author | Maria Matejka <mq@ucw.cz> | 2023-05-07 17:30:33 +0200 |
---|---|---|
committer | Maria Matejka <mq@ucw.cz> | 2023-05-09 10:33:23 +0200 |
commit | 318ac8720fcf5ab14ef794d36947870abb7d85f9 (patch) | |
tree | 777283bf323801c75b8d237096ab6d6634797614 | |
parent | cb51ff1fbb83c15fece1f6c4fa3e538dc137d186 (diff) |
OLocks in BGP must be freed early
-rw-r--r-- | nest/proto.c | 9 | ||||
-rw-r--r-- | nest/protocol.h | 2 | ||||
-rw-r--r-- | proto/bgp/bgp.c | 2 |
3 files changed, 11 insertions, 2 deletions
diff --git a/nest/proto.c b/nest/proto.c index 647b7f4e..c07560c6 100644 --- a/nest/proto.c +++ b/nest/proto.c @@ -1157,11 +1157,15 @@ proto_event(void *ptr) p->do_stop = 0; } - if (proto_is_done(p)) + if (proto_is_done(p) && p->pool_fragile) /* perusing pool_fragile to do this once only */ + { + rp_free(p->pool_fragile); + p->pool_fragile = NULL; if (p->loop != &main_birdloop) birdloop_stop_self(p->loop, proto_loop_stopped, p); else proto_cleanup(p); + } } @@ -1235,7 +1239,10 @@ proto_start(struct proto *p) p->iface_sub.target = proto_event_list(p); PROTO_LOCKED_FROM_MAIN(p) + { + p->pool_fragile = rp_newf(p->pool, birdloop_domain(p->loop), "Protocol %s fragile objects", p->cf->name); proto_notify_state(p, (p->proto->start ? p->proto->start(p) : PS_UP)); + } } diff --git a/nest/protocol.h b/nest/protocol.h index 02ec5c15..e8f19801 100644 --- a/nest/protocol.h +++ b/nest/protocol.h @@ -130,6 +130,8 @@ struct proto { struct proto_config *cf; /* Configuration data */ struct proto_config *cf_new; /* Configuration we want to switch to after shutdown (NULL=delete) */ pool *pool; /* Pool containing local objects */ + pool *pool_fragile; /* Pool containing fragile local objects which need to be freed + before the protocol's birdloop actually stops, like olocks */ event *event; /* Protocol event */ timer *restart_timer; /* Timer to restart the protocol from limits */ event *restart_event; /* Event to restart/shutdown the protocol from limits */ diff --git a/proto/bgp/bgp.c b/proto/bgp/bgp.c index f4d80e8d..9d81b85b 100644 --- a/proto/bgp/bgp.c +++ b/proto/bgp/bgp.c @@ -1742,7 +1742,7 @@ bgp_start(struct proto *P) * so that we are the only instance attempting to talk with that neighbor. */ struct object_lock *lock; - lock = p->lock = olock_new(P->pool); + lock = p->lock = olock_new(P->pool_fragile); lock->addr = p->remote_ip; lock->port = p->cf->remote_port; lock->iface = p->cf->iface; |