(FILECREATED " 9-Dec-84 18:43:19" {ERIS}<LISPCORE>SOURCES>LEAFPATCH.;1 2835   

      changes to:  (VARS LEAFPATCHCOMS))


(* Copyright (c) 1984 by Xerox Corporation. All rights reserved.)

(PRETTYCOMPRINT LEAFPATCHCOMS)

(RPAQQ LEAFPATCHCOMS ((FNS \LEAF.HANDLE.INPUT)))
(DEFINEQ

(\LEAF.HANDLE.INPUT
  [LAMBDA (PUP SEQUIN)                                       (* bvm: " 9-Dec-84 18:31")
                                                             (* Called when a data sequin arrives)
    (PROG ((PUPDATA (fetch PUPCONTENTS of PUP))
	   DONEPUP DONEPUPDATA ERROR OPCODE STREAM)

          (* * Under current scheme, where every requesting packet is responded to by exactly one packet, we "know" that PUP 
	  matches up with the head of SEQDONEQ. The error checking here is thus for protocol violation and is optional)


          (SETQ DONEPUP (\DEQUEUE (fetch SEQDONEQ of SEQUIN)))
          [COND
	    ((NOT DONEPUP)
	      (RETURN (SHOULDNT "Leaf lost a packet somewhere!"]
          (add (fetch SEQINPUTQLENGTH of SEQUIN)
	       -1)
          [COND
	    ((ZEROP (fetch ANSWERBIT of PUPDATA))
	      (HELP "Leaf Protocol violation--will terminate connection" (fetch SEQNAME of SEQUIN))
	      (RETURN (RELEASE.PUP PUP]
          (COND
	    ((EQ (SETQ OPCODE (fetch LEAFOPCODE of PUPDATA))
		 \LEAFOP.ERROR)
	      (SETQ OPCODE (fetch LEAFERROROPCODE of PUPDATA))
	      (SETQ ERROR T)))
          (COND
	    ((AND (NEQ (fetch LEAFOPCODE of (SETQ DONEPUPDATA (fetch PUPCONTENTS of DONEPUP)))
		       OPCODE)
		  LEAFDEBUGFLG)                              (* Protocol violation, but the buggy Vax server does 
							     this)
	      (HELP "Answer does not match head of done queue" PUP))
	    ((AND ERROR (NOT (fetch LEAFALLOWERRORS of DONEPUP)))
	      (replace LEAFSTATUS of PUP with (fetch LEAFERRORCODE of DONEPUPDATA))
	      (SETQ STREAM (fetch EPUSERFIELD of DONEPUP))
	      (COND
		((type? STREAM STREAM)
		  (add (fetch LEAFERRORCNT of STREAM)
		       1)))
	      (replace EPUSERFIELD of DONEPUP with PUP)
	      (ADD.PROCESS (LIST (QUOTE \LEAF.ERROR)
				 PUP
				 (KWOTE STREAM)
				 SEQUIN DONEPUP)))
	    ((fetch LEAFANSWERWANTED of DONEPUP)             (* Match the request with its response;
							     requestor will watch this slot.
							     Eventually change this to a NOTIFY)
	      (replace EPUSERFIELD of DONEPUP with PUP))
	    (T (RELEASE.PUP PUP)
	       (RELEASE.PUP DONEPUP])
)
(PUTPROPS LEAFPATCH COPYRIGHT ("Xerox Corporation" 1984))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (281 2755 (\LEAF.HANDLE.INPUT 291 . 2753)))))
STOP