Good day,

mail> If no exception occurred while sending the request or reading the
mail> response (which was done by another function), the connection would
mail> close normally. However, if an excepton occurred, the stream would not
mail> be closed, and the connection would remain forever in the CLOSE_WAIT
mail> state. And when the no. of connections reaches 1000, the site would
mail> become completely unresponsive and on connecting to lisp, we see the
mail> GC occuring repeatedly (as if in an infinite loop). Also, lisp's CPU
mail> usage goes to 99%. On quitting lisp, all those connections are closed.

Look at FORCIBLY-CLOSE-STREAM function in Araneida source,
file compat/compat-cmucl.lisp:

(defun forcibly-close-stream (s)
  (let ((fd (sys:fd-stream-fd s)))
    (multiple-value-bind (r e) (ignore-errors (close s) t)
      (unless r
        (format t "Unable to close fd ~A: ~A, trying harder ~%" fd e)
        (multiple-value-bind (r e) (ignore-errors (close s :abort t) t)
          (unless r
            (format t "still unable to close ~A: ~A, try harder ~%" fd e)
            (multiple-value-bind (r e)
                (ignore-errors (unix:unix-close fd) t)
              (unless r
                (format t "Even unix-close failed on ~A:~A, giving up~%"
                        fd e)))))))))

It helped me in the same situation.

Best Regards,
Vladimir Sekissov

Reply via email to