[nio-cvs] r89 - in branches/home/psmith/restructure/src: event io nio-logger

psmith at common-lisp.net psmith at common-lisp.net
Sat Feb 17 23:42:29 UTC 2007


Author: psmith
Date: Sat Feb 17 18:42:28 2007
New Revision: 89

Modified:
   branches/home/psmith/restructure/src/event/epoll-cffi.lisp
   branches/home/psmith/restructure/src/event/epoll.lisp
   branches/home/psmith/restructure/src/event/event-notification.lisp
   branches/home/psmith/restructure/src/io/async-fd.lisp
   branches/home/psmith/restructure/src/io/nio-server.lisp
   branches/home/psmith/restructure/src/nio-logger/run-logging-client.lisp
   branches/home/psmith/restructure/src/nio-logger/run-logging-server.lisp
Log:
Hopefully fixes epollhup not handled properly on close

Modified: branches/home/psmith/restructure/src/event/epoll-cffi.lisp
==============================================================================
--- branches/home/psmith/restructure/src/event/epoll-cffi.lisp	(original)
+++ branches/home/psmith/restructure/src/event/epoll-cffi.lisp	Sat Feb 17 18:42:28 2007
@@ -57,10 +57,15 @@
     (fd :int)
     (pad :uint32))
 
+;;See man epoll_ctl
+;;See /usr/include/sys/epoll.h
+
   (defconstant +epoll-event-size+ #.(+ 4 4 4))
 
   (defconstant +epoll-in+ #x001)
   (defconstant +epoll-out+ #x004)
+  (defconstant +epoll-error+ #x008)
+  (defconstant +epoll-hup+ #x010)
   (defconstant +epoll-et+ #.(ash 1 31)) 
 
   (defconstant +epoll-ctl-add+ 1)

Modified: branches/home/psmith/restructure/src/event/epoll.lisp
==============================================================================
--- branches/home/psmith/restructure/src/event/epoll.lisp	(original)
+++ branches/home/psmith/restructure/src/event/epoll.lisp	Sat Feb 17 18:42:28 2007
@@ -40,7 +40,11 @@
   (defun write-event-p (event)
     (not (eql (logand event +epoll-out+) 0)))
 
+  (defun error-event-p (event)
+    (not (eql (logand event +epoll-error+) 0)))
 
+  (defun hup-event-p (event)
+    (not (eql (logand event +epoll-hup+) 0)))
 
   (defun add-fd (event-queue fd mode &key (trigger :edge))
     (with-foreign-object (ev 'epoll-event)

Modified: branches/home/psmith/restructure/src/event/event-notification.lisp
==============================================================================
--- branches/home/psmith/restructure/src/event/event-notification.lisp	(original)
+++ branches/home/psmith/restructure/src/event/event-notification.lisp	Sat Feb 17 18:42:28 2007
@@ -26,4 +26,4 @@
 |#
 (defpackage :event-notification (:use :cl :cffi :nio-compat)
 	    (:export
-	     make-event-queue add-fd remove-fd poll-events poll-error read-event-p write-event-p))
\ No newline at end of file
+	     make-event-queue add-fd remove-fd poll-events poll-error read-event-p write-event-p error-event-p hup-event-p))
\ No newline at end of file

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	Sat Feb 17 18:42:28 2007
@@ -98,7 +98,7 @@
 	  (cond ((eql errno +ERRNO_EAGAIN+)
 		 (setf (read-ready state-machine) nil))
 		(t
-		 (close-fd (read-fd async-fd))
+		 (close-fd (read-fd state-machine))
 		 (error 'read-error :errno errno)))))
        ((= new-bytes 0)
 	nil);;(throw 'end-of-file nil)

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	Sat Feb 17 18:42:28 2007
@@ -147,8 +147,11 @@
 							  (force-close-async-fd async-fd)
 							  (throw 'error-exit nil))))
 
-			     (when (read-event-p event) (setf (read-ready async-fd) t))
-			     (when (write-event-p event) (setf (write-ready async-fd) t)))))))))
+			     (if (error-event-p event) 
+				 (close-sm async-fd)
+				 (progn
+				   (when (read-event-p event) (setf (read-ready async-fd) t))
+				   (when (write-event-p event) (setf (write-ready async-fd) t)))))))))))
 
 ;add outgoing sockets to event queue
 #+nio-debug2     (format-log t "nio-server:start-server - Processing new connections queue ~A~%" +connected-sockets-queue+)

Modified: branches/home/psmith/restructure/src/nio-logger/run-logging-client.lisp
==============================================================================
--- branches/home/psmith/restructure/src/nio-logger/run-logging-client.lisp	(original)
+++ branches/home/psmith/restructure/src/nio-logger/run-logging-client.lisp	Sat Feb 17 18:42:28 2007
@@ -25,7 +25,7 @@
 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 |#
 
-;(push :nio-debug *features*)
+(push :nio-debug *features*)
 (require :asdf)
 (require :nio-logger)
 
@@ -39,7 +39,7 @@
   (setf sb-ext:*invoke-debugger-hook*
 	(lambda (condition hook)
 	  (declare (ignore hook))
-	  (with-open-file (out (format nil "error-from-pid~A-thread-~A" (sb-posix:getpid) (sb-thread:thread-name sb-thread:*current-thread*))
+	  (with-open-file (out (format nil "client-error-from-pid~A-thread-~A" (sb-posix:getpid) (sb-thread:thread-name sb-thread:*current-thread*))
 			       :direction :output :external-format :utf-8 :if-exists :append :if-does-not-exist :create)
 	    (format out "Toplevel catch (~A):~%" (nio-utils:get-readable-time))
 	    (format out "~A - ~A~%" (type-of condition) condition)

Modified: branches/home/psmith/restructure/src/nio-logger/run-logging-server.lisp
==============================================================================
--- branches/home/psmith/restructure/src/nio-logger/run-logging-server.lisp	(original)
+++ branches/home/psmith/restructure/src/nio-logger/run-logging-server.lisp	Sat Feb 17 18:42:28 2007
@@ -25,7 +25,7 @@
 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 |#
 
-;(push :nio-debug *features*)
+(push :nio-debug *features*)
 (require :asdf)
 (require :nio-logger)
 
@@ -33,4 +33,17 @@
       (out-file (third sb-ext:*posix-argv*))
       (allowed-ips-filename (fourth sb-ext:*posix-argv*)))
   (format t "Starting logging Server with ~A ~A ~A~%" listen-ip out-file allowed-ips-filename)
+
+  (setf sb-ext:*invoke-debugger-hook*
+	(lambda (condition hook)
+	  (declare (ignore hook))
+	  (with-open-file (out (format nil "server-error-from-pid~A-thread-~A" (sb-posix:getpid) (sb-thread:thread-name sb-thread:*current-thread*))
+			       :direction :output :external-format :utf-8 :if-exists :append :if-does-not-exist :create)
+	    (format out "Toplevel catch (~A):~%" (nio-utils:get-readable-time))
+	    (format out "~A - ~A~%" (type-of condition) condition)
+	    (sb-debug:backtrace 20 out))
+	  (quit)))
+
+
+
   (nio-logger:run-logging-server listen-ip out-file allowed-ips-filename))



More information about the Nio-cvs mailing list