;;;  -*- Mode:Common-Lisp; Package:IP; Patch-file:T; Base:10 -*-
;;;
;;;  Two changes here:
;;;    1.  Move the condition-case outside the loop so the specials don't get bound,
;;;	   unbound, and rebound every time around.
;;;    2.  Change the high-water-mark default to number-of-input-buffers instead of
;;;	   (1- number-of-input-buffers).  It seems to help the MIPS supdup hang problem.
;;;
;;;               pf


;(DEFMETHOD (character-input-stream-mixin :load-receives)
;	   (&optional (high-water-mark (* (1- number-of-input-buffers) input-buffer-size)))
;  (DO ()
;      ((OR fin-received-p
;	   (> (+ pending-octet-count pending-receives) high-water-mark)))
;    ;; prevent a race condition between fin arrival and issuing a receive
;    (CONDITION-CASE ()
;	(PROGN
;	 (INCF pending-receives input-buffer-size)
;	 (MULTIPLE-VALUE-BIND (length push-p urgent-p) (SEND connection :receive input-buffer-size)
;	   (WHEN length (SEND self :buffer-handler length push-p urgent-p))))
;      (connection-closing))))



(DEFMETHOD (character-input-stream-mixin :load-receives)
	   (&optional (high-water-mark (* number-of-input-buffers input-buffer-size)))
   ;; prevent a race condition between fin arrival and issuing a receive
   (CONDITION-CASE ()
       (DO ()
	   ((OR fin-received-p
		(> (+ pending-octet-count pending-receives) high-water-mark)))
	 (INCF pending-receives input-buffer-size)
	 (MULTIPLE-VALUE-BIND (length push-p urgent-p) (SEND connection :receive input-buffer-size)
	   (WHEN length (SEND self :buffer-handler length push-p urgent-p))))
     (connection-closing)))
