]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: fix thread_cancel_event()
authorJorge Boncompte [DTI2] <jorge@dti2.net>
Mon, 7 May 2012 15:17:31 +0000 (15:17 +0000)
committerDavid Lamparter <equinox@diac24.net>
Mon, 21 May 2012 13:41:21 +0000 (15:41 +0200)
  ospfd was crashing some times on neighbour going down. The cause was that
ospf_nsm_event() was accessing already freed memory in ospf_nbr_delete()
call from ospf_nsm_event().

  What happens is that since commit b5043aab (lib: fix incorrect thread
list...) now a thread can be on the event and ready lists but
thread_cancel_event() doesn't account for that.

* thread.c: (thread_cancel_event) loop on the ready list too to cancel
  pending events.

Signed-off-by: Jorge Boncompte [DTI2] <jorge@dti2.net>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
lib/thread.c

index b36c43a9a640b52d78d68fba1e42b3c6958c450d..dd0413b3477a8c4380ab3754c4d09b92458d13b0 100644 (file)
@@ -916,6 +916,24 @@ thread_cancel_event (struct thread_master *m, void *arg)
           thread_add_unuse (m, t);
         }
     }
+
+  /* thread can be on the ready list too */
+  thread = m->ready.head;
+  while (thread)
+    {
+      struct thread *t;
+
+      t = thread;
+      thread = t->next;
+
+      if (t->arg == arg)
+        {
+          ret++;
+          thread_list_delete (&m->ready, t);
+          t->type = THREAD_UNUSED;
+          thread_add_unuse (m, t);
+        }
+    }
   return ret;
 }