]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Events now return a value. If it's non-zero, the event is re-queued
authorMartin Mares <mj@ucw.cz>
Fri, 29 Oct 1999 12:08:49 +0000 (12:08 +0000)
committerMartin Mares <mj@ucw.cz>
Fri, 29 Oct 1999 12:08:49 +0000 (12:08 +0000)
for processing in next event cycle. This can be used to prevent background
actions (hint: user commands) from hogging the CPU for too long time.

lib/event.c
lib/event.h
nest/proto.c
nest/rt-table.c

index 962c64098dba216cb85a737e774cde2cbf66634b..e9ae3be76f19676a43080f104eb45dbff987c58b 100644 (file)
@@ -53,8 +53,8 @@ ev_new(pool *p)
 inline void
 ev_run(event *e)
 {
-  e->hook(e->data);
-  ev_postpone(e);
+  if (!e->hook(e->data))
+    ev_postpone(e);
 }
 
 inline void
@@ -74,14 +74,11 @@ ev_schedule(event *e)
 void
 ev_run_list(event_list *l)
 {
-  for(;;)
+  node *n, *p;
+
+  WALK_LIST_DELSAFE(n, p, *l)
     {
-      node *n = HEAD(*l);
-      event *e;
-      if (!n->next)
-       break;
-      e = SKIP_BACK(event, n, n);
+      event *e = SKIP_BACK(event, n, n);
       ev_run(e);
     }
 }
-
index 0b1ea84287700fe895b5f6fc9c8bf93af8391d1f..0856fbb0990330f874e557296b64d7c195491677 100644 (file)
@@ -13,7 +13,7 @@
 
 typedef struct event {
   resource r;
-  void (*hook)(void *);
+  int (*hook)(void *);
   void *data;
   node n;                              /* Internal link */
 } event;
index bbf5d59814fd243a64222dfa50b0986aba92da08..3430176faf5f4fd8a9ba300e979a64479ccb5424 100644 (file)
@@ -36,7 +36,7 @@ static event *proto_flush_event;
 static char *p_states[] = { "DOWN", "START", "UP", "STOP" };
 static char *c_states[] = { "HUNGRY", "FEEDING", "HAPPY", "FLUSHING" };
 
-static void proto_flush_all(void *);
+static int proto_flush_all(void *);
 
 static void
 proto_enqueue(list *l, struct proto *p)
@@ -329,7 +329,7 @@ proto_fell_down(struct proto *p)
   proto_rethink_goal(p);
 }
 
-static void
+static int
 proto_feed(void *P)
 {
   struct proto *p = P;
@@ -341,6 +341,7 @@ proto_feed(void *P)
   p->core_state = FS_HAPPY;
   proto_relink(p);
   DBG("Protocol %s up and running\n", p->name);
+  return 0;
 }
 
 void
@@ -401,7 +402,7 @@ proto_notify_state(struct proto *p, unsigned ps)
   proto_relink(p);
 }
 
-static void
+static int
 proto_flush_all(void *unused)
 {
   struct proto *p;
@@ -417,4 +418,5 @@ proto_flush_all(void *unused)
       proto_relink(p);
       proto_fell_down(p);
     }
+  return 0;
 }
index 0f423f8bbd8d2e922f5e97d10dd173b17e4b8c41..353473d10bccc783e7dcef50bd4f6d8b8f6a54e0 100644 (file)
@@ -395,7 +395,7 @@ rt_dump_all(void)
     rt_dump(t);
 }
 
-static void
+static int
 rt_gc(void *unused)
 {
   rtable *t;
@@ -404,6 +404,7 @@ rt_gc(void *unused)
   rt_prune_all();
   rt_last_gc = now;
   rt_gc_counter = 0;
+  return 0;
 }
 
 void