;;; -*- Mode:Lisp; Readtable:CL; Package:USER; Base:10; Patch-File:T -*-
;;; Patch file for System version 123.157
;;; Reason:
;;;  Network receiver can loop if there are no buffers available and an interface has a
;;;  packet ready.
;;; Written 8-Dec-87 15:38:03 by pld at site Gigamos Cambridge
;;; while running on Jack Flanders from band 2
;;; with Experimental System 123.154, Experimental Local-File 73.3, Experimental FILE-Server 22.1, Experimental Unix-Interface 11.0, Experimental Tape 18.0, Experimental KERMIT 34.0, Experimental ZMail 71.0, Experimental Lambda-Diag 15.0, microcode 1754, SDU Boot Tape 3.12, SDU ROM 8.



; From modified file DJ: L.NETWORK.DRIVERS; DRIVER-PROCESS.LISP#46 at 8-Dec-87 15:38:03
#10R NETWORK#: 
(COMPILER-LET ((*PACKAGE* (GLOBAL:PKG-FIND-PACKAGE "NETWORK")))
  (COMPILER::PATCH-SOURCE-FILE "SYS: NETWORK; DRIVERS; DRIVER-PROCESS  "

(defun get-next-packet-wait-function ()
  (dolist (ni (car *network-interface-fifo*))
    (and (ni-enabled ni)
	 (cond ((ni-reserved-receive-buffer ni)
		;;If we have a buffer, cool
		t)
	       ((ni-need-receive-buffer ni)
		;;If we need a buffer, it is only cool if we can now get one
		(when (setf (ni-reserved-receive-buffer ni) (allocate-packet nil))
		  (setf (ni-need-receive-buffer ni) nil)
		  t))
	       ((ni-packet-ready-function ni)
		;;Otherwise, call the packet ready function, if any
		(funcall (ni-packet-ready-function ni))))
	 (return ni))))

))
