[Openmcl-devel] process-input-wait question

Erik Pearson erik at adaptations.com
Thu Jul 13 07:03:29 UTC 2006


I've been looking at the implementation code for process-input-wait  
and fd-input-available, and was  wondering if Gary or anyone could  
address a couple of questions?

First, why does the underlying "select()" call in fd-input-available  
utilizes the exception argument (errfds in the lisp, but exceptfds in  
the man page for select).  The purpose of exceptfds is to detect, on  
sockets (for which I'm using this), the availability of out-of-band  
data. The naming of the lisp variable "errfds" might lead one to  
believe that the authors at some point believed it was an "exception"  
as in "error" rather than "exception"  as in "interesting" or  
"different" as it seems to mean in this context.

Other than this not being documented -- is the inclusion of the  
exceptfds test desirable? I don't know if the openmcl code makes room  
for oob shenanigans, which I don't really understand. I don't think  
that oob is part of the http spec as far as my present application,  
so I'd rather be able to ignore it completely.

I've modified the code a bit to return whether this condition has  
been detected when process-input-wait returns, and sometimes it is  
and sometimes it isn't (this is on a connection from a web browser to  
a lisp web server). I'm not sure I have the desire to figure out why.

Another process-input-wait question has to do with the initial call  
to fd-input-available with a ticks argument of 0, and the subsequent  
calling of fd-input-available with the timeout ticks, the testing of  
ticks, etc. This looks like a little bit of polling -- but isn't  
select with the timeout value supposed to work as expected -- to  
return as soon as the selected file descriptors are available, or the  
time has passed, and isn't that just what we want? Perhaps this is to  
work around some bugs, or fine points in select logic that I don't  
understand?

defun process-input-wait (fd &optional ticks)
   "Wait until input is available on a given file-descriptor."
   (let* ((wait-end (if ticks (+ (get-tick-count) ticks))))
     (loop
        (when (fd-input-available-p fd 0)
	 (return t))
        (let* ((now (if ticks (get-tick-count))))
	 (if (and wait-end (>= now wait-end))
	     (return))
	 (fd-input-available-p fd (if ticks (- wait-end now)))))))


  Is there any reason that this won't work?

(defun process-input-wait (fd &optional ticks)
   "Wait until input is available on a given file-descriptor."
   (fd-input-available-p fd ticks))

Thanks,
Erik.



More information about the Openmcl-devel mailing list