From f7c2a886c9fb73b2749d5e270f15b79c44e72a62 Mon Sep 17 00:00:00 2001 From: Maria Matejka Date: Tue, 24 Jan 2023 11:01:34 +0100 Subject: Object locks use events Instead of calling custom hooks from object locks, we use standard event sending mechanism to inform protocols about object lock changes. As event sending is lockless, the unlocking protocol simply enqueues the appropriate event to the given loop when the locking is done. --- proto/rip/rip.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'proto/rip/rip.c') diff --git a/proto/rip/rip.c b/proto/rip/rip.c index bd087246..b3a4e81e 100644 --- a/proto/rip/rip.c +++ b/proto/rip/rip.c @@ -667,9 +667,9 @@ rip_iface_update_bfd(struct rip_iface *ifa) static void -rip_iface_locked(struct object_lock *lock) +rip_iface_locked(void *_ifa) { - struct rip_iface *ifa = lock->data; + struct rip_iface *ifa = _ifa; struct rip_proto *p = ifa->rip; if (!rip_open_socket(ifa)) @@ -731,8 +731,11 @@ rip_add_iface(struct rip_proto *p, struct iface *iface, struct rip_iface_config lock->type = OBJLOCK_UDP; lock->port = ic->port; lock->iface = iface; - lock->data = ifa; - lock->hook = rip_iface_locked; + lock->event = (event) { + .hook = rip_iface_locked, + .data = ifa, + }; + lock->target = &global_event_list; ifa->lock = lock; olock_acquire(lock); -- cgit v1.2.3