[nio-cvs] r70 - branches/home/psmith/restructure/src/io
psmith at common-lisp.net
psmith at common-lisp.net
Mon Feb 5 04:51:52 UTC 2007
Author: psmith
Date: Sun Feb 4 23:51:51 2007
New Revision: 70
Modified:
branches/home/psmith/restructure/src/io/async-fd.lisp
branches/home/psmith/restructure/src/io/nio-server.lisp
Log:
Large packet support working
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 4 23:51:51 2007
@@ -77,7 +77,9 @@
(with-slots (close-pending) async-fd
(setf close-pending t)))
-(define-condition read-error (error) ())
+(define-condition read-error (error)
+ ((errno :initform :errno
+ :accessor read-error-errno)))
;; "Read more data from STATE-MACHINE."
(defun read-more (state-machine)
@@ -88,16 +90,19 @@
#+nio-debug (format t "read-more : Read ~A bytes into ~A~%" new-bytes foreign-read-buffer)
(cond
((< new-bytes 0)
- (progn
-;;TODO if ret is -1 and errno is EAGAIN save state and wait for notification
- (format t "read-error - Errno: ~A~%" (get-errno))
- (error 'read-error)))
+ (let ((errno (get-errno)))
+ (format t "read-error - Errno: ~A~%" errno)
+ (cond ((eql errno +ERRNO_EAGAIN+)
+ (setf (read-ready state-machine) nil))
+ (t
+ (error 'read-error :errno errno)))))
((= new-bytes 0)
nil);;(throw 'end-of-file nil)
(t
;;Update buffer position
(inc-position foreign-read-buffer new-bytes)
- (setf (read-ready state-machine) nil))))))
+ (when (> (remaining foreign-read-buffer) 0)
+ (setf (read-ready state-machine) nil)))))))
(defun close-async-fd (async-fd)
"Close ASYNC-FD's fd after everything has been written from write-queue."
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 4 23:51:51 2007
@@ -109,7 +109,12 @@
;; accept connection ?
((funcall accept-connection async-fd)
- (set-fd-nonblocking (async-fd-read-fd async-fd))
+ (sleep 0.1)
+ (let ((nb-ret (set-fd-nonblocking (async-fd-read-fd async-fd))))
+ (format t "set bb ret: ~A :flags ~A~%" nb-ret (get-fd-flags (async-fd-read-fd async-fd)))
+ (when (< nb-ret 0)
+ (format t "Error setting socket non-blocking: ")
+ (perror)))
(setf (gethash (async-fd-read-fd async-fd) client-hash) async-fd)
(add-async-fd event-queue async-fd :read-write)
; (add-async-fd event-queue async-fd :write)
More information about the Nio-cvs
mailing list