[hunchentoot-devel] Truncated responses from Hunchentoot

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)))))

Hi Ilya, thank you for the bug report. On Sat, Feb 5, 2011 at 1:20 AM, Ilya Perminov <iperminov@dwavesys.com> wrote:
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)
I think that the right fix is to call FINISH-OUTPUT in PROCESS-CONNECTION instead. I have committed http://bknr.net/trac/changeset/4641, can you please try that patch and let us know if it helps? Thanks, Hans
participants (2)
-
Hans Hübner
-
Ilya Perminov