[usocket-cvs] r658 - in usocket/branches/0.5.x: . backend

Chun Tian (binghe) ctian at common-lisp.net
Wed May 11 07:24:38 UTC 2011


Author: ctian
Date: Wed May 11 03:24:37 2011
New Revision: 658

Log:
[ECL] Port fixes of issue elliott-slaughter.2 from SBCL to ECL (untested); Update ChangeLog

Modified:
   usocket/branches/0.5.x/CHANGES
   usocket/branches/0.5.x/backend/sbcl.lisp

Modified: usocket/branches/0.5.x/CHANGES
==============================================================================
--- usocket/branches/0.5.x/CHANGES	(original)
+++ usocket/branches/0.5.x/CHANGES	Wed May 11 03:24:37 2011
@@ -4,7 +4,7 @@
 * Bugfix: [CLISP] WAIT-FOR-INPUT now functions right (with/without READY-ONLY), this made Hunchentoot working on CLISP. (Thanks to Anton Vodonosov <avodonosov at yandex.ru>)
 * Bugfix: [ABCL] Fix SOCKET-ACCEPT to follow the documented API so that when called without an :ELEMENT-TYPE argument. (Thanks to Mark Evenson, the ABCL developer)
 * Bugfix: [LispWorks] Fixed SOCKET-ACCEPT (Windows only) on WAIT-FOR-INPUTed sockets.
-* Bugfix: [SBCL] Fixed missing STATE clean for WAIT-FOR-INPUT on SBCL/Windows (report by Elliott Slaughter)
+* Bugfix: [SBCL, ECL] Fixed wrongly STATE set/unset for WAIT-FOR-INPUT on Windows (report by Elliott Slaughter)
 * Enhancement: Additional NAME keyword argument for SOCKET-SERVER for setting the server thread name.
 * Enhancement: [ABCL] GET-ADDRESS now works with underlying IP6 addresses.
 * Enhancement: [CLISP] missing GET-LOCAL-* methods for STREAM-SERVER-USOCKET was now added.

Modified: usocket/branches/0.5.x/backend/sbcl.lisp
==============================================================================
--- usocket/branches/0.5.x/backend/sbcl.lisp	(original)
+++ usocket/branches/0.5.x/backend/sbcl.lisp	Wed May 11 03:24:37 2011
@@ -738,7 +738,8 @@
      '%remove-waiter))
 
   ;; TODO: how to handle error (result) in this call?
-  (defun bytes-available-for-read (socket)
+  (declaim (inline %bytes-available-for-read))
+  (defun %bytes-available-for-read (socket)
     (ffi:c-inline ((socket-handle socket)) (:fixnum) :fixnum
      "u_long nbytes;
       int result;
@@ -746,11 +747,15 @@
       result = ioctlsocket((SOCKET)#0, FIONREAD, &nbytes);
       @(return) = nbytes;"))
 
+  (defun bytes-available-for-read (socket)
+    (let ((nbytes (%bytes-available-for-read socket)))
+      (when (plusp nbytes)
+	(setf (state socket) :read))
+      nbytes))
+
   (defun update-ready-and-state-slots (sockets)
     (dolist (socket sockets)
-      (if (or (and (stream-usocket-p socket)
-                   (listen (socket-stream socket))) ; TODO: LISTEN cannot be used
-              (%ready-p socket))
+      (if (%ready-p socket)
           (setf (state socket) :READ)
         (let ((events (etypecase socket
                         (stream-server-usocket (logior fd-connect fd-accept fd-close))
@@ -765,8 +770,10 @@
                   @(return) = (#1 & network_events.lNetworkEvents)? Ct : Cnil;
                 } else
                   @(return) = Cnil;")
-              (setf (%ready-p socket) t
-                    (state socket) :READ)
+              (progn
+		(setf (state socket) :READ)
+		(when (stream-server-usocket-p socket)
+		  (setf (%ready-p socket) t)))
             (sb-bsd-sockets::socket-error 'update-ready-and-state-slots))))))
 
   (defun wait-for-input-internal (wait-list &key timeout)




More information about the usocket-cvs mailing list