[nio-cvs] r86 - branches/home/psmith/restructure/src/io

psmith at common-lisp.net psmith at common-lisp.net
Mon Feb 12 03:29:07 UTC 2007


Author: psmith
Date: Sun Feb 11 22:29:06 2007
New Revision: 86

Modified:
   branches/home/psmith/restructure/src/io/async-fd.lisp
   branches/home/psmith/restructure/src/io/nio-server.lisp
Log:
tidied up close TODO detect remote close properly

Modified: branches/home/psmith/restructure/src/io/async-fd.lisp
==============================================================================
--- branches/home/psmith/restructure/src/io/async-fd.lisp	(original)
+++ branches/home/psmith/restructure/src/io/async-fd.lisp	Sun Feb 11 22:29:06 2007
@@ -98,6 +98,7 @@
 	  (cond ((eql errno +ERRNO_EAGAIN+)
 		 (setf (read-ready state-machine) nil))
 		(t
+		 (close-fd (read-fd async-fd))
 		 (error 'read-error :errno errno)))))
        ((= new-bytes 0)
 	nil);;(throw 'end-of-file nil)
@@ -148,7 +149,7 @@
 	  (unless (eql err 11) ;; eagain - failed to write whole buffer need to wait for next notify
 	    (perror)
 	    (let ((err-cond (make-instance 'write-error :error err)))
-	      (close-fd (write-fd async-fd))
+	      (close-fd (write-fd async-fd)); - deal with in nio-server?
 	      (error err-cond))))
 	;;update buffers
 	(if (eql (remaining foreign-write-buffer) 0)

Modified: branches/home/psmith/restructure/src/io/nio-server.lisp
==============================================================================
--- branches/home/psmith/restructure/src/io/nio-server.lisp	(original)
+++ branches/home/psmith/restructure/src/io/nio-server.lisp	Sun Feb 11 22:29:06 2007
@@ -43,12 +43,14 @@
     (maphash #'(lambda (k async-fd) 
 #+nio-debug	(format-log t "Dealing with ~a => ~a~%" k async-fd)
 	       
-	       ;process reads
-	       (when (read-ready async-fd) (read-more async-fd))
-	       (when (> (buffer-position (foreign-read-buffer async-fd)) 0)
-		 (process-read async-fd))
-
-	       ;process-writes
+;process reads
+               (handler-case
+		   (progn
+		     (when (read-ready async-fd) (read-more async-fd))
+		     (when (> (buffer-position (foreign-read-buffer async-fd)) 0)
+		       (process-read async-fd)))
+		 (read-error (re) (push async-fd removals)))
+;process-writes
 	       (handler-case
 		   (progn
 		     (process-write async-fd)
@@ -63,6 +65,7 @@
 	   client-hash)
     (dolist (async-fd removals)
       (format-log t "nio-server:process-async-fds processing remove for ~a~%" async-fd)
+      (close-sm async-fd)
       (setf (active-conn (socket async-fd)) nil)
       (remhash (async-fd-read-fd async-fd) client-hash))))
   			     



More information about the Nio-cvs mailing list