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

psmith at common-lisp.net psmith at common-lisp.net
Sat Feb 3 03:20:03 UTC 2007


Author: psmith
Date: Fri Feb  2 22:20:01 2007
New Revision: 64

Modified:
   branches/home/psmith/restructure/src/io/async-fd.lisp
   branches/home/psmith/restructure/src/nio-logger/nio-logger.lisp
Log:
logger updates

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	Fri Feb  2 22:20:01 2007
@@ -136,6 +136,7 @@
 	(let ((err (get-errno)))
 	  (format t "write-more - write returned -1 :errno ~A~%" err)
 	  (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 err-cond)
 	      (error err-cond))))

Modified: branches/home/psmith/restructure/src/nio-logger/nio-logger.lisp
==============================================================================
--- branches/home/psmith/restructure/src/nio-logger/nio-logger.lisp	(original)
+++ branches/home/psmith/restructure/src/nio-logger/nio-logger.lisp	Fri Feb  2 22:20:01 2007
@@ -29,6 +29,18 @@
 
 (declaim (optimize (debug 3) (speed 3) (space 0)))
 
+
+
+(defmacro with-line-from-tailed-file ((line filename delay) &rest body)
+  `(with-open-file (in ,filename :direction :input)
+     (loop for ,line = (read-line in nil nil) do
+	  (if ,line
+	      (progn , at body)
+	      (progn
+		(format t "read nil~%")
+		(sleep ,delay))))))
+
+
 ;;Tail the given log and write to remote logger
 ;;e.g. (tail-log "/var/log/httpd/access_log" "192.168.1.1")
 (defun tail-log(filename ip-address)
@@ -37,11 +49,10 @@
   (sleep 4)
   (let ((sm (nio:add-connection ip-address 16323 'nio-yarpc:yarpc-client-state-machine)))
     (nio-utils:format-log t "toplevel adding conn ~A to ~A~%" sm ip-address)
-    (with-open-file (in filename :direction :input)
-      (loop for text = (read-line in nil nil) do
-    	(let ((rpc (format nil "(nio-logger:remote-log \"~A\")" text)))
-	  (nio-utils:format-log t "Toplevel Submitting job~A~%" rpc)
-	  (nio-utils:format-log t "Result of remote-log ~A~%" (nio-yarpc:remote-execute sm rpc)))))))
+    (with-line-from-tailed-file (text filename 1)
+      (let ((rpc (format nil "(nio-logger:remote-log \"~A\")" text)))
+	(nio-utils:format-log t "Toplevel Submitting job~A~%" rpc)
+	(nio-utils:format-log t "Result of remote-log ~A~%" (nio-yarpc:remote-execute sm rpc))))))
 
 ;Runs a multithreaded system with an IO thread dealing with IO only and a 'job'  thread taking and executing jobs
 
@@ -57,4 +68,6 @@
 
 (nio-yarpc:defremote remote-log(str)
   (with-open-file (out +log-file-name+ :direction :output :if-exists :append)
-    (nio-utils:format-log out "~A~%" str)))
+    (nio-utils:format-log out "~A~%" str))
+  t)
+



More information about the Nio-cvs mailing list