r5230: First upload
[cl-modlisp.git] / impl-cmucl.lisp
1 ;;; -*- Mode:Lisp; Syntax:Common-lisp; Package: modlisp; Base:10 -*-
2
3 (in-package #:modlisp)
4
5
6 (defun make-socket-server (name function port &key wait (format :text))
7   (mp:make-process
8    (lambda () (make-apache-listener port function))
9    :name name))
10
11 (defun make-apache-listener (port function)
12   (let ((socket (ext:create-inet-listener port)))
13     (unwind-protect
14          (loop
15           (mp:process-wait-until-fd-usable socket :input)
16           (multiple-value-bind (new-fd remote-host)
17               (ext:accept-tcp-connection socket)
18             (let ((stream (sys:make-fd-stream new-fd :input t :output t)))
19               (mp:make-process
20                (lambda () (apache-command-issuer stream function))
21                :name (next-worker-name)))))
22       (unix:unix-close socket))))