From 0576e90fe46eade354e7b0f0ead0c03a9b916621 Mon Sep 17 00:00:00 2001
From: Vladimir Sedach <vsedach@gmail.com>
Date: Mon, 16 Nov 2009 02:52:04 -0500
Subject: [PATCH 4/5] Added a flags parameter to MONITOR-FD multiplexer method.

---
 src/multiplex/backend-kqueue.lisp |    4 ++--
 src/multiplex/backend-poll.lisp   |    2 +-
 src/multiplex/backend-select.lisp |    2 +-
 src/multiplex/multiplexer.lisp    |   15 ++++++++-------
 4 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/src/multiplex/backend-kqueue.lisp b/src/multiplex/backend-kqueue.lisp
index 7954328..e54b71a 100644
--- a/src/multiplex/backend-kqueue.lisp
+++ b/src/multiplex/backend-kqueue.lisp
@@ -34,8 +34,8 @@
       isys:evfilt-write
       isys:evfilt-read))
 
-(defmethod monitor-fd ((mux kqueue-multiplexer) fd-entry)
-  (assert fd-entry (fd-entry) "Must supply an FD-ENTRY!")
+(defmethod monitor-fd ((mux kqueue-multiplexer) (fd-entry fd-entry) &optional flags)
+  (declare (ignore flags))
   (handler-case
       (do-kqueue-event-request (fd-of mux) fd-entry
                                (calc-kqueue-monitor-filter fd-entry)
diff --git a/src/multiplex/backend-poll.lisp b/src/multiplex/backend-poll.lisp
index f89e356..6ca4d4c 100644
--- a/src/multiplex/backend-poll.lisp
+++ b/src/multiplex/backend-poll.lisp
@@ -48,7 +48,7 @@
     (foreign-free fd-set)
     (values new-fd-set new-size)))
 
-(defmethod monitor-fd ((mux poll-multiplexer) fd-entry)
+(defmethod monitor-fd ((mux poll-multiplexer) (fd-entry fd-entry) &optional flags)
   (let ((fd (fd-entry-fd fd-entry))
         (readp (fd-entry-read-handler fd-entry))
         (writep (fd-entry-write-handler fd-entry)))
diff --git a/src/multiplex/backend-select.lisp b/src/multiplex/backend-select.lisp
index 56f0ea3..4da03c0 100644
--- a/src/multiplex/backend-select.lisp
+++ b/src/multiplex/backend-select.lisp
@@ -61,7 +61,7 @@
                         (find-max-fd ws end))))
     t))
 
-(defmethod monitor-fd ((mux select-multiplexer) fd-entry)
+(defmethod monitor-fd ((mux select-multiplexer) (fd-entry fd-entry) &optional flags)
   (recalc-fd-masks mux (fd-entry-fd fd-entry)
                    (fd-entry-read-handler fd-entry)
                    (fd-entry-write-handler fd-entry)))
diff --git a/src/multiplex/multiplexer.lisp b/src/multiplex/multiplexer.lisp
index 331c29e..76d536d 100644
--- a/src/multiplex/multiplexer.lisp
+++ b/src/multiplex/multiplexer.lisp
@@ -30,7 +30,7 @@
   (:method-combination progn :most-specific-last)
   (:documentation "Close multiplexer MUX, calling close() on the multiplexer's FD if bound."))
 
-(defgeneric monitor-fd (mux fd-entry)
+(defgeneric monitor-fd (mux fd-entry &optional flags)
   (:documentation "Add the descriptor reppresented by FD-ENTRY to multiplexer MUX.
 Must return NIL on failure, T otherwise."))
 
@@ -61,12 +61,13 @@ Returns a list of fd/result pairs which have one of these forms:
     (setf (slot-value mux 'fd) nil))
   (values mux))
 
-(defmethod monitor-fd :before ((mux multiplexer) fd-entry)
-  (with-accessors ((fd-limit fd-limit-of))
-      mux
-    (let ((fd (fd-entry-fd fd-entry)))
-      (when (and fd-limit (> fd fd-limit))
-        (error "Cannot add such a large FD: ~A" fd)))))
+(defmethod monitor-fd :before ((mux multiplexer) fd-entry &optional flags)
+  (declare (ignore flags))
+  (let ((fd (if (integerp fd-entry)
+                fd-entry
+                (fd-entry-fd fd-entry))))
+    (when (and (fd-limit-of mux) (> fd (fd-limit-of mux)))
+      (error "Cannot add such a large FD: ~A" fd))))
 
 (defmacro define-multiplexer (name priority superclasses slots &rest options)
   `(progn
-- 
1.6.3.3

