]> git.ipfire.org Git - thirdparty/bird.git/blobdiff - nest/locks.c
Merge remote-tracking branch 'origin/master' into mq-filter-stack
[thirdparty/bird.git] / nest / locks.c
index 7044d6a9849129a7a6b10e0bc224ae07790734fd..812a65342268b9b97b3f19f1960c8e8b5e07377c 100644 (file)
  * or some other non-shareable resource, it asks the core to lock it and it doesn't
  * use the resource until it's notified that it has acquired the lock.
  *
- * Object locks are represented by &object_lock structures which are in turn a kind of
- * resource. Lockable resources are uniquely determined by resource type
+ * Object locks are represented by &object_lock structures which are in turn a
+ * kind of resource. Lockable resources are uniquely determined by resource type
  * (%OBJLOCK_UDP for a UDP port etc.), IP address (usually a broadcast or
- * multicast address the port is bound to), port number and interface.
+ * multicast address the port is bound to), port number, interface and optional
+ * instance ID.
  */
 
 #undef LOCAL_DEBUG
@@ -44,7 +45,9 @@ olock_same(struct object_lock *x, struct object_lock *y)
   return
     x->type == y->type &&
     x->iface == y->iface &&
+    x->vrf == y->vrf &&
     x->port == y->port &&
+    x->inst == y->inst &&
     ipa_equal(x->addr, y->addr);
 }
 
@@ -68,7 +71,7 @@ olock_free(resource *r)
          DBG("olock: -> %p becomes locked\n", n);
          q = SKIP_BACK(struct object_lock, n, n);
          rem_node(n);
-         add_tail_list(&l->waiters, &q->waiters);
+         add_tail_list(&q->waiters, &l->waiters);
          q->state = OLOCK_STATE_EVENT;
          add_head(&olock_list, n);
          ev_schedule(olock_event);
@@ -88,7 +91,7 @@ olock_dump(resource *r)
   struct object_lock *l = (struct object_lock *) r;
   static char *olock_states[] = { "free", "locked", "waiting", "event" };
 
-  debug("(%d:%s:%I:%d) [%s]\n", l->type, (l->iface ? l->iface->name : "?"), l->addr, l->port, olock_states[l->state]);
+  debug("(%d:%s:%I:%d:%d) [%s]\n", l->type, (l->iface ? l->iface->name : "?"), l->addr, l->port, l->inst, olock_states[l->state]);
   if (!EMPTY_LIST(l->waiters))
     debug(" [wanted]\n");
 }
@@ -98,7 +101,8 @@ static struct resclass olock_class = {
   sizeof(struct object_lock),
   olock_free,
   olock_dump,
-  NULL
+  NULL,
+  NULL,
 };
 
 /**
@@ -187,6 +191,5 @@ olock_init(void)
 {
   DBG("olock: init\n");
   init_list(&olock_list);
-  olock_event = ev_new(&root_pool);
-  olock_event->hook = olock_run_event;
+  olock_event = ev_new_init(&root_pool, olock_run_event, NULL);
 }