Correcting contract and caching host-table
svn: r696
This commit is contained in:
parent
cc259d1c90
commit
67360f2843
|
@ -80,11 +80,10 @@
|
||||||
(lambda (the-exn)
|
(lambda (the-exn)
|
||||||
(output-response/method
|
(output-response/method
|
||||||
conn
|
conn
|
||||||
((responders-servlet-loading (host-responders
|
((responders-servlet-loading
|
||||||
host-info)) uri
|
(host-responders host-info))
|
||||||
the-exn)
|
uri the-exn)
|
||||||
(request-method req)))])
|
(request-method req)))])
|
||||||
|
|
||||||
(let ([sema (make-semaphore 0)]
|
(let ([sema (make-semaphore 0)]
|
||||||
[last-inst (thread-cell-ref current-servlet-instance)])
|
[last-inst (thread-cell-ref current-servlet-instance)])
|
||||||
(let/cc suspend
|
(let/cc suspend
|
||||||
|
@ -180,7 +179,6 @@
|
||||||
(or (and (directory-exists? base) base)
|
(or (and (directory-exists? base) base)
|
||||||
(loop base))))))
|
(loop base))))))
|
||||||
|
|
||||||
|
|
||||||
;; invoke-servlet-continuation: connection request continuation-reference
|
;; invoke-servlet-continuation: connection request continuation-reference
|
||||||
;; host -> void
|
;; host -> void
|
||||||
;; pull the continuation out of the table and apply it
|
;; pull the continuation out of the table and apply it
|
||||||
|
|
|
@ -128,7 +128,7 @@
|
||||||
(response/full-body resp))))]
|
(response/full-body resp))))]
|
||||||
[(response/incremental? resp)
|
[(response/incremental? resp)
|
||||||
(output-response/incremental conn resp)]
|
(output-response/incremental conn resp)]
|
||||||
[(and (pair? resp) (string? (car resp)))
|
[(and (pair? resp) (bytes? (car resp)))
|
||||||
(output-response/basic
|
(output-response/basic
|
||||||
conn
|
conn
|
||||||
(make-response/basic 200 "Okay" (current-seconds) (car resp) '())
|
(make-response/basic 200 "Okay" (current-seconds) (car resp) '())
|
||||||
|
|
|
@ -150,28 +150,44 @@
|
||||||
;; NOTE: (GregP) I'm going to use the dispatch logic out of v208 for now.
|
;; NOTE: (GregP) I'm going to use the dispatch logic out of v208 for now.
|
||||||
;; I will move the other dispatch logic out of the prototype
|
;; I will move the other dispatch logic out of the prototype
|
||||||
;; at a later time.
|
;; at a later time.
|
||||||
(define (dispatch conn req)
|
(define dispatch
|
||||||
(let* ([host (get-host (request-uri req) (request-headers req))]
|
(let* ([cache (make-hash-table 'equal)]
|
||||||
[host-info (config:virtual-hosts host)])
|
[sema (make-semaphore 1)]
|
||||||
((host-log-message host-info) (request-host-ip req)
|
[lookup-dispatcher
|
||||||
(request-client-ip req) (request-method req) (request-uri req) host)
|
(lambda (host host-info)
|
||||||
((sequencer:gen-dispatcher
|
(hash-table-get
|
||||||
(passwords:gen-dispatcher host-info config:access)
|
cache host
|
||||||
(path-procedure:gen-dispatcher "/conf/collect-garbage"
|
(lambda ()
|
||||||
(lambda ()
|
(call-with-semaphore
|
||||||
(collect-garbage)
|
sema (lambda ()
|
||||||
((responders-collect-garbage (host-responders host-info)))))
|
(hash-table-get
|
||||||
(servlets:gen-dispatcher host-info
|
cache host
|
||||||
config:instances config:scripts config:scripts-lock config:make-servlet-namespace)
|
(lambda () (host-info->dispatcher host-info))))))))])
|
||||||
(files:gen-dispatcher host-info))
|
(lambda (conn req)
|
||||||
conn req)))))
|
(let* ([host (get-host (request-uri req) (request-headers req))]
|
||||||
|
[host-info (config:virtual-hosts host)])
|
||||||
|
((host-log-message host-info) (request-host-ip req)
|
||||||
|
(request-client-ip req) (request-method req) (request-uri req) host)
|
||||||
|
((lookup-dispatcher host host-info)
|
||||||
|
conn req)))))
|
||||||
|
|
||||||
|
(define (host-info->dispatcher host-info)
|
||||||
|
(sequencer:gen-dispatcher
|
||||||
|
(passwords:gen-dispatcher host-info config:access)
|
||||||
|
(path-procedure:gen-dispatcher "/conf/collect-garbage"
|
||||||
|
(lambda ()
|
||||||
|
(collect-garbage)
|
||||||
|
((responders-collect-garbage (host-responders host-info)))))
|
||||||
|
(servlets:gen-dispatcher host-info
|
||||||
|
config:instances config:scripts config:scripts-lock config:make-servlet-namespace)
|
||||||
|
(files:gen-dispatcher host-info)))))
|
||||||
|
|
||||||
(define web-server@
|
(define web-server@
|
||||||
(compound-unit/sig
|
(compound-unit/sig
|
||||||
(import (TCP : net:tcp^)
|
(import (TCP : net:tcp^)
|
||||||
(CONFIG : web-config^))
|
(CONFIG : web-config^))
|
||||||
(link (DISPATCH : dispatch-server^
|
(link (DISPATCH-CONFIG : dispatch-server-config^
|
||||||
(dispatch-server@ TCP DISPATCH-CONFIG))
|
(web-config@->dispatch-server-config@ CONFIG))
|
||||||
(DISPATCH-CONFIG : dispatch-server-config^
|
(DISPATCH : dispatch-server^
|
||||||
(web-config@->dispatch-server-config@ CONFIG)))
|
(dispatch-server@ TCP DISPATCH-CONFIG)))
|
||||||
(export (open (DISPATCH : web-server^))))))
|
(export (open (DISPATCH : web-server^))))))
|
Loading…
Reference in New Issue
Block a user