;;;; Programmer: Kevin M. Rosenberg
;;;; Date Started: Dec 2002
;;;;
-;;;; $Id: base.lisp,v 1.1 2003/07/04 19:52:32 kevin Exp $
+;;;; $Id: base.lisp,v 1.2 2003/07/04 22:41:06 kevin Exp $
;;;; *************************************************************************
(in-package #:modlisp)
(*listener-process* nil))
(defun modlisp-start (&key (port +default-apache-port+)
- (function 'sample-process-apache-command))
+ (function 'demo-apache-command-processor))
(handler-case
- (make-socket-server (next-server-name) function port :format :text
- :wait nil)
+ (make-socket-server (next-server-name) function port
+ :format :text :wait nil)
(error (e)
(format t "Error ~A" e)
(decf *listener-count*)
nil)
- (:no-error (proc socket)
+ (:no-error (process socket)
(setq *listener-socket* socket)
- (setq *listener-proc* proc)
- proc)))
-
+ (setq *listener-process* process)
+ process)))
+
(defun modlisp-stop ()
- (when *listener-proc*
- (format t "~&; killing ~d~%" *listener-proc*)
- #+sbcl (sb-unix:unix-kill *listener-proc* :sigalrm)
- #+allegro (mp:process-kill *listener-proc*)
+ (when *listener-process*
+ (format t "~&; killing process ~d~%" *listener-process*)
+ #+sbcl (sb-thread:destory-thread *listener-process*)
+ #+allegro (mp:process-kill *listener-process*)
#+allegro (mp:process-allow-schedule)
- )
- (setq *listener-proc* nil)
+ #+lispworks (mp:process-kill *listener-process*)
+ #+cmucl (mp:destroy process *listener-process*)
+ (setq *listener-process* nil))
(when *listener-socket*
(ignore-errors (close *listener-socket*))
(setq *listener-socket* nil)))
(format nil "modlisp-worker-~d" (incf *worker-count*)))
-(defun apache-command-issuer (*apache-socket*
- &optional
- (processor-fun 'demo-apache-command-processor))
+(defun apache-command-issuer (*apache-socket* processor-fun)
"generates commands from apache, issues commands to processor-fun"
(let ((*close-apache-socket* t))
(unwind-protect
(defun debug-table (command)
(with-output-to-string (s)
(write-string "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">
-<HTML><HEAD></HEAD><BODY><TABLE bgcolor=\"#c0c0c0\">
-<TR bgcolor=\"yellow\"><TH COLSPAN=2>ACL 6.2 + mod_lisp 2.0 + apache + Linux</TH></TR>
-<TR bgcolor=\"yellow\"><TH>Key</TH><TH>Value</TH></TR>" s)
+<html><head></head>
+<body>
+<table><tbody>
+<tr><t colspan=\"2\">mod_lisp debug</th></tr>
+<tr><th>Key</th><th>Value</th></tr>" s)
(format s "<TR bgcolor=\"#F0F0c0\"><TD>apache-nb-use-socket</TD><TD>~a</TD></TR>" *apache-nb-use-socket*)
(loop for (key . value) in command do
- (format s "<TR bgcolor=\"#F0F0c0\"><TD>~a</TD><TD>~a</TD></TR>" key value))
- (write-string "</TABLE></BODY></HTML>" s)))
+ (format s "<tr><td>~a</td><td>~a</td></tr>" key value))
+ (write-string "</tbody></table></body></html>" s)))
(defun fixed-html ()
"<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">
-<HTML><HEAD></HEAD><BODY><H1>mod_lisp 2.0</H1><P>This is a constant
- html string sent by mod_lisp</P></BODY></HTML>")
+<html><head></head><body><h1>mod_lisp</h1>
+<p>This is a constant html string sent by mod_lisp</p></body></html>")
+++ /dev/null
-;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10; Package: modlisp -*-
-;;;; *************************************************************************
-;;;; FILE IDENTIFICATION
-;;;;
-;;;; Name: base.lisp
-;;;; Purpose: Base data and functions for modlisp package
-;;;; Programmer: Kevin M. Rosenberg
-;;;; Date Started: Dec 2002
-;;;;
-;;;; $Id: data-structures.lisp,v 1.1 2003/07/04 19:52:32 kevin Exp $
-;;;; *************************************************************************
-
-(in-package #:modlisp)
-
-(defvar *listener-count* 0
- "used to name listeners")
-
-(defvar *worker-count* 0
- "used to name workers")
-
-(defvar *listener-socket*
- "Socket for the listener")
-
-(defvar *listener-proc* nil
- "Process for the listener")
-
-(defconstant +default-apache-port+ 13244
- "Default port for listen")
-
-(defvar *apache-socket* nil
- "the socket stream to apache")
-
-(defvar *close-apache-socket* nil
- "set to T if you want to close the socket to apache after
-the current command")
-
-(defvar *apache-nb-use-socket* 0
- "the number of requests sent in this socket")
-
Package: cl-modlisp
Architecture: all
-Depends: ${shlibs:Depends}, common-lisp-controller (>= 3.37),libapache-mod-lisp
+Depends: ${shlibs:Depends}, common-lisp-controller (>= 3.37),libapache-mod-lisp,cl-kmrcl
Description: Common Lisp interface to the Apache mod-lisp module
cl-modlisp provides a Common Lisp interface to the mod-lisp Apache module.
The package has support for CMUCL, SBCL, CLISP, AllegroCL, and Lispworks.
:wait wait)))))
(values proc listener)))
-(defun worker-process (stream function conn count)
- (unwind-protect
- #+ignore
- (funcall function conn)
-
- (excl:errorset (close conn) nil)))
-
(defun start-socket-server (passive-socket function &key wait)
;; internal function run in the server lightweight process
;; that continually processes the connection.
;; This code is careful to ensure that the sockets are
;; properly closed something abnormal happens.
(unwind-protect
- (loop (let ((connection (socket:accept-connection passive-socket)))
- (if wait
- (unwind-protect
- (funcall connection function)
- (excl:errorset (close connection) nil))
- (let ((f function)
- (c connection)
- (name (next-worker-name))
- (mp:process-run-function
- name
- #'(lambda ()
- (unwind-protect
- (apache-command-issuer connection function)
- #+ignore
- (handler-case
- (apache-command-issuer function connection)
- (error (e)
- #+ignore
- (format t "~&Error ~A [~A]~%" e name))
- (:no-error ()
- #+ignore
- (format t "~&~A ended" name)))
- (excl:errorset (close connection) nil)))
- )))))
+ (loop
+ (let ((connection (socket:accept-connection passive-socket)))
+ (if wait
+ (unwind-protect
+ (funcall connection function)
+ (excl:errorset (close connection) nil))
+ (let ((f function)
+ (c connection)
+ (name (next-worker-name)))
+ (mp:process-run-function
+ name
+ #'(lambda ()
+ (unwind-protect
+ (apache-command-issuer connection function)
+ #+ignore
+ (handler-case
+ (apache-command-issuer function connection)
+ (error (e)
+ #+ignore
+ (format t "~&Error ~A [~A]~%" e name))
+ (:no-error ()
+ #+ignore
+ (format t "~&~A ended" name)))
+ (excl:errorset (close connection) nil))))))))
(ignore-errors (close passive-socket))))
;;;; Programmer: Kevin M. Rosenberg
;;;; Date Started: Dec 2002
;;;;
-;;;; $Id: modlisp.asd,v 1.1 2003/07/04 19:52:32 kevin Exp $
+;;;; $Id: modlisp.asd,v 1.2 2003/07/04 22:41:06 kevin Exp $
;;;; *************************************************************************
(defpackage #:modlisp-system (:use #:cl #:asdf))
#+(or allegro clisp cmu lispworks sbcl)
(defsystem modlisp
- :default-component-class kboot:kmr-cl-source-file
- :depends-on (:kmrcl
- :base64
- #+sbcl :sb-bsd-sockets)
+ :depends-on (:kmrcl #+sbcl :sb-bsd-sockets)
:components
((:file "package")
- (:file "data-structures" :depends-on ("package"))
+ (:file "variables" :depends-on ("package"))
(:file #+allegro "impl-acl"
#+clisp "impl-clisp"
#+cmu "impl-cmucl"
#+sbcl "impl-sbcl"
#+lispworks "impl-lispworks"
- :depends-on ("data-structures"))
+ :depends-on ("variables"))
(:file "base"
:depends-on (#+allegro "impl-acl"
#+clisp "impl-clisp"
--- /dev/null
+;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10; Package: modlisp -*-
+;;;; *************************************************************************
+;;;; FILE IDENTIFICATION
+;;;;
+;;;; Name: base.lisp
+;;;; Purpose: Base data and functions for modlisp package
+;;;; Programmer: Kevin M. Rosenberg
+;;;; Date Started: Dec 2002
+;;;;
+;;;; $Id: variables.lisp,v 1.1 2003/07/04 22:41:06 kevin Exp $
+;;;; *************************************************************************
+
+(in-package #:modlisp)
+
+(defvar *listener-count* 0
+ "used to name listeners")
+
+(defvar *worker-count* 0
+ "used to name workers")
+
+(defvar *listener-socket*
+ "Socket for the listener")
+
+(defvar *listener-proc* nil
+ "Process for the listener")
+
+(defconstant +default-apache-port+ 20123
+ "Default port for listen")
+
+(defvar *apache-socket* nil
+ "the socket stream to apache")
+
+(defvar *close-apache-socket* nil
+ "set to T if you want to close the socket to apache after
+the current command")
+
+(defvar *apache-nb-use-socket* 0
+ "the number of requests sent in this socket")
+