[iolib-devel] Patch for a nil callback invocation.

Peter Keller psilord at cs.wisc.edu
Wed Mar 3 03:18:31 UTC 2010


Hello,

After a talk with Stelian about the previous version of this patch, I see
now my initial solution was incorrect. Here is a corrected version of it.

The purpose of this patch is to fix %remove-handlers and %dispatch-event
so they don't try to invoke or otherwise misuse a NIL callback handler
on a ready socket.

Thank you.

-pete



diff --git a/src/multiplex/event-loop.lisp b/src/multiplex/event-loop.lisp
index 35879fd..a0b6ab1 100644
--- a/src/multiplex/event-loop.lisp
+++ b/src/multiplex/event-loop.lisp
@@ -313,7 +313,7 @@ within the extent of BODY.  Closes VAR."
         (when (and eventsp one-shot) (setf exit-p t))))))
 
 (defun %remove-handlers (event-base event-list)
-  (loop :for ev :in event-list
+  (loop :for ev :in (remove-if #'null event-list)
         :for fd := (fd-handler-fd ev)
         :for fd-entry := (fd-entry-of event-base fd)
      :do (%remove-io-handler event-base fd fd-entry ev)))
@@ -352,13 +352,14 @@ within the extent of BODY.  Closes VAR."
 
 (defun %dispatch-event (fd-entry event-type errorp now)
   (let ((ev (fd-entry-handler fd-entry event-type)))
-    (funcall (fd-handler-callback ev)
-             (fd-entry-fd fd-entry)
-             event-type
-             (if errorp :error nil))
-    (when-let (timer (fd-handler-timer ev))
-      (reschedule-timer-relative-to-now timer now))
-    (fd-handler-one-shot-p ev)))
+    (when ev
+          (funcall (fd-handler-callback ev)
+                   (fd-entry-fd fd-entry)
+                   event-type
+                   (if errorp :error nil))
+          (when-let (timer (fd-handler-timer ev))
+                    (reschedule-timer-relative-to-now timer now))
+          (fd-handler-one-shot-p ev))))
 
 (defun dispatch-fd-timeouts (events)
   (dolist (ev events)





More information about the iolib-devel mailing list