Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 31 Aug 2005 18:03:48 GMT
From:      John Baldwin <jhb@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 82914 for review
Message-ID:  <200508311803.j7VI3mOM017636@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=82914

Change 82914 by jhb@jhb_slimer on 2005/08/31 18:03:41

	Another todo.

Affected files ...

.. //depot/projects/smpng/sys/notes#52 edit

Differences ...

==== //depot/projects/smpng/sys/notes#52 (text+ko) ====

@@ -92,6 +92,49 @@
   locks.  Requested by Jeff.
   + Implemented
   - Untested
+- Fix free race in eventhandlers:
+> In the macro "_EVENTHANDLER_INVOKE" in the file
+> "/sys/sys/eventhandler.h", you unlock the list lock
+> before calling the callback. That make sense. But what
+> happens if one process is in the callback, and another
+> process is deregistering this tag.
+>
+> The solution is that the last thread
+> that has anything to do with a entry
+> frees it:
+>
+> TAILQ_FOREACH()
+> {
+>  refcount++;
+>
+>  EHL_UNLOCK();
+>
+>  callback();
+>
+>  EHL_LOCK();
+>
+>  refcount--;
+>
+>  if(refcount == 0)
+>    free(entry);
+> }
+>
+> At init:
+>  refcount = 1;
+>
+>
+> At deregister:
+>
+> EHL_LOCK();
+>
+> refcount--;
+> if(refcount == 0)
+>   free();
+>
+> EHL_UNLOCK();
+>
+> --HPS
+>
 
 Active child branches:
 - jhb_intr - intr_event stuff



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200508311803.j7VI3mOM017636>