]> git.ipfire.org Git - thirdparty/bird.git/blobdiff - nest/locks.c
Doc: Remove some superfluous slashes
[thirdparty/bird.git] / nest / locks.c
index c1f7331e59a3c92d0381d76b34b17c293b518091..86c9ff1469747e1752f299bb18fa515922087a63 100644 (file)
  * occur only when the user specifies an invalid configuration and therefore
  * he deserves to get what he has asked for, but unfortunately they can also
  * arise legitimately when the daemon is reconfigured and there exists (although
- * for a short time period only) an old protocol being shut down and a new one
+ * for a short time period only) an old protocol instance being shut down and a new one
  * willing to start up on the same interface.
  *
  * The solution is very simple: when any protocol wishes to use a network port
- * or some other non-shareable resource, it asks the core to lock it and doesn't
+ * 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 which is 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");
 }
@@ -97,7 +100,9 @@ static struct resclass olock_class = {
   "ObjLock",
   sizeof(struct object_lock),
   olock_free,
-  olock_dump
+  olock_dump,
+  NULL,
+  NULL,
 };
 
 /**
@@ -153,7 +158,7 @@ olock_acquire(struct object_lock *l)
 }
 
 static void
-olock_run_event(void *unused)
+olock_run_event(void *unused UNUSED)
 {
   node *n;
   struct object_lock *q;