[hunchentoot-devel] Truncated responses from Hunchentoot
Ilya Perminov
iperminov at dwavesys.com
Sat Feb 5 00:20:11 UTC 2011
Hi,
I use Hunchentoot 1.1.1 with SBCL 1.0.43 under Linux. Under load
Hunchentoot sometimes sends incomplete responses to the clients. I tried
to debug the problem and Hunchentoot seems to close the output
stream without waiting for the buffered data to be sent.
In "connection per request" mode (i.e. keep-alive is disabled),
immediately after writing a response to the output stream
function PROCESS-CONNECTION makes the following calls:
(force-output *hunchentoot-stream*)
(close *hunchentoot-stream* :abort t)
As FORCE-OUTPUT does not wait till all the buffered output is sent, CLOSE
(with :ABORT T) is sometimes called before the buffers are empty and
discards a part of the output.
I wrote a small test to demonstrate the problem. The server and the
client has to run on different computers.
Regards,
Ilya
;; ======================== Server ==============
(require :hunchentoot)
(defparameter *port* 8085)
(defparameter *data-len* 50000)
(hunchentoot:start (make-instance 'hunchentoot:acceptor :port *port*))
(hunchentoot:define-easy-handler (test-handler :uri "/test") ()
(make-string *data-len* :initial-element #\a))
;; =============== Client ===================
(require :drakma)
(defparameter *host* "lich")
(defparameter *port* 8085)
(defparameter *data-len* 50000)
(defun test ()
(multiple-value-bind (res status-code)
(drakma:http-request (format nil "http://~a:~a/test" *host* *port*))
(assert (= status-code 200))
(assert (= (length res) *data-len*))
(assert (equalp res (make-string *data-len* :initial-element #\a)))))
(dotimes (n 10) (sb-thread:make-thread (lambda () (dotimes (i 1000) (test)))))
More information about the Tbnl-devel
mailing list