[nio-cvs] r23 - in branches/home/psmith/restructure: . src src/io src/protocol/http

psmith at common-lisp.net psmith at common-lisp.net
Thu Jan 4 01:55:34 UTC 2007


Author: psmith
Date: Wed Jan  3 20:55:33 2007
New Revision: 23

Added:
   branches/home/psmith/restructure/README
   branches/home/psmith/restructure/src/io/nio-server.lisp
      - copied, changed from r22, branches/home/psmith/restructure/src/nio-server.lisp
Removed:
   branches/home/psmith/restructure/src/nio-server.lisp
Modified:
   branches/home/psmith/restructure/run.lisp
   branches/home/psmith/restructure/src/io/async-fd.lisp
   branches/home/psmith/restructure/src/io/nio-package.lisp
   branches/home/psmith/restructure/src/io/nio.asd
   branches/home/psmith/restructure/src/protocol/http/http-response.lisp
   branches/home/psmith/restructure/src/protocol/http/http-state-machine.lisp
   branches/home/psmith/restructure/src/protocol/http/nio-http-package.lisp
Log:
moved nio-server into nio package
narrowed nio external i/f
back to base working case after restructure



Added: branches/home/psmith/restructure/README
==============================================================================
--- (empty file)
+++ branches/home/psmith/restructure/README	Wed Jan  3 20:55:33 2007
@@ -0,0 +1,5 @@
+To run install asd's
+
+sbcl --load run.lisp
+
+wget http://localhost:16323/index.html

Modified: branches/home/psmith/restructure/run.lisp
==============================================================================
--- branches/home/psmith/restructure/run.lisp	(original)
+++ branches/home/psmith/restructure/run.lisp	Wed Jan  3 20:55:33 2007
@@ -1,5 +1,4 @@
 (push :nio-debug *features*)
 (require :asdf)
 (require :nio-http)
-(load "src/nio-server")
-(nio-server:start-server 'identity 'identity 'nio-http:http-state-machine :host "127.0.0.1")
+(nio:start-server 'identity 'identity 'nio-http:http-state-machine :host "127.0.0.1")

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	Wed Jan  3 20:55:33 2007
@@ -40,10 +40,12 @@
 
 
 (defclass async-fd ()
-  ((write-fd :initarg :write-fd)
+  ((write-fd :initarg :write-fd
+  	     :accessor write-fd)
 ;;   (write-queue :initform nil)
 
-   (read-fd :initarg :read-fd)
+   (read-fd :initarg :read-fd
+            :accessor read-fd)
 
    (foreign-read-buffer :initform (byte-buffer 4096))
    (foreign-write-buffer :initform (byte-buffer 4096)
@@ -69,16 +71,25 @@
 
    ))
 
-;'http-state-machine
+
+(defmethod print-object ((async-fd async-fd) stream)
+  (with-slots (read-fd write-fd) async-fd
+    (format stream "#<ASYNC-FD r/w fd: ~D/~D.>"
+	    read-fd write-fd)))
+
+
+;;SM factory
 (defun create-state-machine(sm-type read-fd write-fd socket)
   (let ((sm (make-instance sm-type :read-fd read-fd :write-fd write-fd :socket socket)))
+    (format t "create-state-machine - Created ~S~%" sm)
     (nio-buffer:flip (foreign-write-buffer sm))
     sm))
 
-;;override this in concrete SM for read
-(defmethod process-read((async-fd async-fd))())
+;;Implement this in concrete SM for read
+(defgeneric process-read (async-fd))
 
 ;;override this in concrete SM for close
+;(defmethod process-close((async-fd async-fd)reason)())
 (defmethod process-close((async-fd async-fd)reason)())
 
 
@@ -89,13 +100,6 @@
       (setf close-pending t)))
 
 
-
-(defmethod print-object ((async-fd async-fd) stream)
-  (with-slots (read-fd write-fd) async-fd
-    (format stream "#<ASYNC-FD r/w fd: ~D/~D.>~%"
-	    read-fd write-fd)))
-
-
 (defclass packet ()
   ((buffer  :initarg :buffer  :initform nil :documentation "Foreign array")
    (size    :initarg :size    :initform 0)
@@ -114,7 +118,7 @@
 ;;  "Read more data from STATE-MACHINE."
 (defun read-more (state-machine)
   (with-slots (foreign-read-buffer read-fd) state-machine
-#+nio-debug  (format t "read-more called with ~A~%" state-machine)
+  (format t "read-more called with ~A~%" state-machine)
 
 #+nio-debug      (format t "read-more - calling read()~%") 
     (let ((new-bytes (%read read-fd (buffer-buf foreign-read-buffer) (remaining foreign-read-buffer))))

Modified: branches/home/psmith/restructure/src/io/nio-package.lisp
==============================================================================
--- branches/home/psmith/restructure/src/io/nio-package.lisp	(original)
+++ branches/home/psmith/restructure/src/io/nio-package.lisp	Wed Jan  3 20:55:33 2007
@@ -29,15 +29,13 @@
 	    (:export
 
 	     ;; async-fd.lisp
-	     set-fd-nonblocking close-fd read-more write-more
-	     async-write-seq close-async-fd force-close-async-fd
-	     async-fd-read-fd async-fd-write-fd
-	     add-async-fd remove-async-fd
-	     set-accept-filter set-read-callback
-	     read-error async-fd
+	     async-fd process-read foreign-read-buffer foreign-write-buffer close-sm
 
 	     ;; async-socket.lisp
-	     make-inet-socket make-inet6-socket 
-	     bind-inet-socket bind-inet6-socket 
-	     start-listen socket-accept remote-info
+	     
+	     ;;nio-server
+	     start-server
+	     
+	     ;;packet
+	     packet
 	     ))

Copied: branches/home/psmith/restructure/src/io/nio-server.lisp (from r22, branches/home/psmith/restructure/src/nio-server.lisp)
==============================================================================
--- branches/home/psmith/restructure/src/nio-server.lisp	(original)
+++ branches/home/psmith/restructure/src/io/nio-server.lisp	Wed Jan  3 20:55:33 2007
@@ -24,9 +24,7 @@
 INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 |#
-(defpackage :nio-server (:use :cl :nio :event-notification) 
-	    (:export start-server))
-(in-package :nio-server)
+(in-package :nio)
 
 (declaim (optimize (debug 3) (speed 3) (space 0)))
 

Modified: branches/home/psmith/restructure/src/io/nio.asd
==============================================================================
--- branches/home/psmith/restructure/src/io/nio.asd	(original)
+++ branches/home/psmith/restructure/src/io/nio.asd	Wed Jan  3 20:55:33 2007
@@ -8,6 +8,7 @@
 		 (:file "fd-helper" :depends-on ("nio-package"))
 		 (:file "async-fd" :depends-on ("fd-helper"))
 		 (:file "async-socket" :depends-on ("async-fd"))
+		 (:file "nio-server" :depends-on ("async-socket"))
 		 )
 
     :depends-on (:cffi :event-notification :nio-buffer :nio-compat))

Modified: branches/home/psmith/restructure/src/protocol/http/http-response.lisp
==============================================================================
--- branches/home/psmith/restructure/src/protocol/http/http-response.lisp	(original)
+++ branches/home/psmith/restructure/src/protocol/http/http-response.lisp	Wed Jan  3 20:55:33 2007
@@ -69,7 +69,7 @@
 
 (defmethod get-bytes ((http-response http-response))
  (with-slots (status html) http-response
-  (sb-ext:string-to-octets (get-packet status "text/html" html))))
+  (get-packet status "text/html" html)))
 
 
 

Modified: branches/home/psmith/restructure/src/protocol/http/http-state-machine.lisp
==============================================================================
--- branches/home/psmith/restructure/src/protocol/http/http-state-machine.lisp	(original)
+++ branches/home/psmith/restructure/src/protocol/http/http-state-machine.lisp	Wed Jan  3 20:55:33 2007
@@ -31,12 +31,15 @@
 ;; A SM that speaks HTTP
 (defclass http-state-machine (async-fd)())
 
+(defmethod print-object ((sm http-state-machine) stream)
+  (format stream "#<HTTP-STATE-MACHINE ~A >" (call-next-method sm nil)))
+
+
 (defmethod process-read((sm http-state-machine))
   (with-slots (foreign-read-buffer foreign-write-buffer) sm 
 #+nio-debug    (format t "process-read got: ~A~%" (get-string foreign-read-buffer))
 ;;todo create packet and get-bytes
-
-   (get-bytes (http-response :status :ok :html "<html> ock </html>"))
+    (nio-buffer:map-to-foreign foreign-write-buffer (get-bytes (http-response :status :ok :html "<html> ock </html>")))
     (close-sm sm)))
 
 

Modified: branches/home/psmith/restructure/src/protocol/http/nio-http-package.lisp
==============================================================================
--- branches/home/psmith/restructure/src/protocol/http/nio-http-package.lisp	(original)
+++ branches/home/psmith/restructure/src/protocol/http/nio-http-package.lisp	Wed Jan  3 20:55:33 2007
@@ -24,7 +24,7 @@
 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 |#
-(defpackage :nio-http (:use :cl :nio)
+(defpackage :nio-http (:use :cl :nio :nio-buffer)
 	    
 	    (:export
 



More information about the Nio-cvs mailing list