diff options
author | Maria Matejka <mq@ucw.cz> | 2023-01-24 11:01:34 +0100 |
---|---|---|
committer | Maria Matejka <mq@ucw.cz> | 2023-01-26 13:22:28 +0100 |
commit | 05d8c3699d51866c68747167556e7c1f06390afe (patch) | |
tree | f4d02839aa5ad2086779974625e52ba5c2b028d0 /proto/rip/rip.c | |
parent | 4334f86251429eb39bfe81ff19496d141fccef84 (diff) |
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. This is
a backport from version 3 where these events are passed across threads.
This implementation of object locks doesn't use mutexes to lock the
whole data structure. In version 3, this data structure may get accessed
from multiple threads and must be protected by mutex.
Diffstat (limited to 'proto/rip/rip.c')
-rw-r--r-- | proto/rip/rip.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/proto/rip/rip.c b/proto/rip/rip.c index ca218846..93b0d528 100644 --- a/proto/rip/rip.c +++ b/proto/rip/rip.c @@ -656,9 +656,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)) @@ -720,8 +720,10 @@ 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, + }; ifa->lock = lock; olock_acquire(lock); |