From 05d8c3699d51866c68747167556e7c1f06390afe 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. 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. --- proto/babel/babel.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'proto/babel/babel.c') diff --git a/proto/babel/babel.c b/proto/babel/babel.c index ad7981f6..e1b31e86 100644 --- a/proto/babel/babel.c +++ b/proto/babel/babel.c @@ -1762,9 +1762,9 @@ babel_find_iface(struct babel_proto *p, struct iface *what) } static void -babel_iface_locked(struct object_lock *lock) +babel_iface_locked(void *_ifa) { - struct babel_iface *ifa = lock->data; + struct babel_iface *ifa = _ifa; struct babel_proto *p = ifa->proto; if (!babel_open_socket(ifa)) @@ -1819,8 +1819,10 @@ babel_add_iface(struct babel_proto *p, struct iface *new, struct babel_iface_con lock->addr = IP6_BABEL_ROUTERS; lock->port = ifa->cf->port; lock->iface = ifa->iface; - lock->hook = babel_iface_locked; - lock->data = ifa; + lock->event = (event) { + .hook = babel_iface_locked, + .data = ifa, + }; olock_acquire(lock); } -- cgit v1.2.3