[nio-cvs] r36 - in branches/home/psmith/restructure: . src/buffer src/io src/protocol/yarpc src/statemachine

psmith at common-lisp.net psmith at common-lisp.net
Mon Jan 15 04:52:18 UTC 2007


Author: psmith
Date: Sun Jan 14 23:52:17 2007
New Revision: 36

Modified:
   branches/home/psmith/restructure/run-yarpc-client.lisp
   branches/home/psmith/restructure/src/buffer/buffer.lisp
   branches/home/psmith/restructure/src/io/nio-server.lisp
   branches/home/psmith/restructure/src/protocol/yarpc/yarpc-packet-factory.lisp
   branches/home/psmith/restructure/src/protocol/yarpc/yarpc-state-machine.lisp
   branches/home/psmith/restructure/src/statemachine/state-machine.lisp
Log:
yarpc ready to create response packet

Modified: branches/home/psmith/restructure/run-yarpc-client.lisp
==============================================================================
--- branches/home/psmith/restructure/run-yarpc-client.lisp	(original)
+++ branches/home/psmith/restructure/run-yarpc-client.lisp	Sun Jan 14 23:52:17 2007
@@ -6,6 +6,6 @@
 (sleep 4)
 (let ((sm (nio:add-connection "127.0.0.1" 16323 'nio-yarpc:yarpc-state-machine)))
 (format t "toplevel adding conn ~A~%" sm)
-(format t "Result of remote-execute ~A~%" (nio-yarpc:remote-execute sm "(test-rpc-list)")))
+(format t "Result of remote-execute ~A~%" (nio-yarpc:remote-execute sm "(nio-yarpc:test-rpc-list)")))
 
 

Modified: branches/home/psmith/restructure/src/buffer/buffer.lisp
==============================================================================
--- branches/home/psmith/restructure/src/buffer/buffer.lisp	(original)
+++ branches/home/psmith/restructure/src/buffer/buffer.lisp	Sun Jan 14 23:52:17 2007
@@ -121,8 +121,8 @@
 ;reads bytes from byte-buffer and returns a vector (unsigned-byte 8)
 (defmethod bytebuffer-read-vector((bb byte-buffer) &optional (num-bytes-to-read (remaining bb)))
   (let ((vec  (make-uint8-seq num-bytes-to-read)))
-    (with-slots (buf) bb
-      (inc-position bb (cffi:mem-read-vector vec (buffer-buf bb) :unsigned-char num-bytes-to-read)))
+    (with-slots (buf position) bb
+      (inc-position bb (cffi:mem-read-vector vec buf :unsigned-char num-bytes-to-read position)))
     vec))
 
 ; Read bytes from bytebuffer abd return a string using the supplied decoding

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 Jan 14 23:52:17 2007
@@ -92,11 +92,11 @@
 				     (declare (ignore cond))
 				     (format t "Poll-error, exiting..~%")
 				     (throw 'poll-error-exit nil))))
-	
-       (loop for unix-epoll-events = (poll-events event-queue) do
+       
+	(loop 
+	   (let ((unix-epoll-events (poll-events event-queue)))
 	     (loop for (fd . event) in unix-epoll-events do	    
 		  (cond
-		  
 		    ;; new connection
 		    ((= fd sock)
 		     (let ((async-fd (socket-accept fd connection-type)))
@@ -135,7 +135,7 @@
 							  (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))))))))
+			     (when (write-event-p event) (setf (write-ready async-fd) t)))))))))
 	     (format t "Process client adds~%")
 
 					;add outgoing sockets to event queue

Modified: branches/home/psmith/restructure/src/protocol/yarpc/yarpc-packet-factory.lisp
==============================================================================
--- branches/home/psmith/restructure/src/protocol/yarpc/yarpc-packet-factory.lisp	(original)
+++ branches/home/psmith/restructure/src/protocol/yarpc/yarpc-packet-factory.lisp	Sun Jan 14 23:52:17 2007
@@ -43,7 +43,7 @@
 ;  (format t "get-packet::read string - ~A~%" (bytebuffer-read-string buf (remaining buf)))
   (if (>= (remaining buf) 1) ;; First byte denotes packet ID
     (ecase (elt (bytebuffer-read-vector buf 1) 0)
-      (0 (progn (format t "got CALL-METHOD-PACKET-ID~%") (make-instance 'call-method-packet (bytebuffer-read-string buf (remaining buf)))))
+      (0 (progn (format t "got CALL-METHOD-PACKET-ID~%") (make-instance 'call-method-packet :call (bytebuffer-read-string buf (remaining buf)))))
       (1 (format t "got METHOD-RESPONSE-PACKET-ID~%")))))
 
 (defclass call-method-packet (packet)((call-string :initarg :call

Modified: branches/home/psmith/restructure/src/protocol/yarpc/yarpc-state-machine.lisp
==============================================================================
--- branches/home/psmith/restructure/src/protocol/yarpc/yarpc-state-machine.lisp	(original)
+++ branches/home/psmith/restructure/src/protocol/yarpc/yarpc-state-machine.lisp	Sun Jan 14 23:52:17 2007
@@ -100,9 +100,10 @@
 
 
 ;Process a call method packet, returns 
-(defmethod process-incomming-packet ((sm yarpc-state-machine) (call call-method-packet))
+(defmethod process-incoming-packet ((sm yarpc-state-machine) (call call-method-packet))
   ;todo change state, create method-response packet and return it
   ;(assert (eql state 0))
+  (format t "yarpc-state-machine:process-incoming-packet called :sm ~A :packet ~A~%" sm call)
   (handler-case
     (let ((result (execute-call (get-call-string call))))
       (when result 

Modified: branches/home/psmith/restructure/src/statemachine/state-machine.lisp
==============================================================================
--- branches/home/psmith/restructure/src/statemachine/state-machine.lisp	(original)
+++ branches/home/psmith/restructure/src/statemachine/state-machine.lisp	Sun Jan 14 23:52:17 2007
@@ -31,7 +31,7 @@
 ;
 ;Base class for state machines
 ;
-;Converts incomming data between bytes and packets using the supplied packet-factory.
+;Converts incoming data between bytes and packets using the supplied packet-factory.
 ;Converts outgoing data between packets and bytes using the write-bytes method on packet.
 ;
 ;This way only the protocols packet heirarchy knows about binary representations and 
@@ -42,7 +42,7 @@
 (defmethod print-object ((sm state-machine) stream)
   (format stream "#<STATE-MACHINE ~A >" (call-next-method sm nil)))
 
-(defgeneric process-incomming-packet(state-machine packet))
+(defgeneric process-incoming-packet(state-machine packet))
 
 
 (defgeneric process-outgoing-packet(state-machine))
@@ -54,10 +54,10 @@
 ;Use the packet factory to obtain any valid packet and pass it through
 (defmethod process-read((sm state-machine))
   (with-slots (foreign-read-buffer) sm
-    (let ((incomming-packet (get-packet (get-packet-factory sm) foreign-read-buffer)))
-      (format t "state-machine::process-read - incomming packet: ~A~%" incomming-packet)
-      (when incomming-packet 
-      	  (when (not (process-incomming-packet sm incomming-packet))
+    (let ((incoming-packet (get-packet (get-packet-factory sm) foreign-read-buffer)))
+      (format t "state-machine::process-read - incoming packet: ~A~%" incoming-packet)
+      (when incoming-packet 
+      	  (when (not (process-incoming-packet sm incoming-packet))
       	    (close-sm sm))))))
 
 ;The connection is write ready.



More information about the Nio-cvs mailing list