;;; -*- Mode:Lisp; Readtable:ZL; Package:USER; Base:10; Patch-File:T -*-
;;; Patch file for System version 124.38
;;; Reason:
;;;  Funny interaction between the process opening a file via FTP-ACCESS and the wholine:
;;;  If one is in the process of doing a probe to get the property list when the other
;;;  asks for the property list, the second gets a NIL.  Not a problem if the wholine is
;;;  second, but can cause an error if the wholine was first.  Add an interlock.
;;; Written 8-Jun-88 16:13:22 by pld (Peter L. DeWolf) at site Gigamos Cambridge
;;; while running on Azathoth from band 1
;;; with Experimental System 124.37, Experimental Local-File 74.1, Experimental File-Server 23.1, Experimental Unix-Interface 12.0, Experimental ZMail 72.0, Experimental Tape 23.6, Experimental Lambda-Diag 16.1, microcode 1756, SDU Boot Tape 3.14, SDU ROM 8, the old ones.



; From modified file DJ: L.NETWORK.IP-TCP.USER; FTP-ACCESS.LISP#52 at 8-Jun-88 16:42:23
#10R FILE-SYSTEM#: 
(COMPILER-LET ((*PACKAGE* (PKG-FIND-PACKAGE "FILE-SYSTEM")))
  (COMPILER::PATCH-SOURCE-FILE "SYS: NETWORK; IP-TCP; USER; FTP-ACCESS  "

(defflavor ftp-file-stream-mixin
	   (truename pathname
	    (status :open)
	    actual
	    host-unit
	    byte-size
	    support-plistp
	    (probe-stream nil)
	    (property-list-lock nil))
	   (si:file-stream-mixin si:file-data-stream-mixin si:property-list-mixin)
  :initable-instance-variables)

))

; From modified file DJ: L.NETWORK.IP-TCP.USER; FTP-ACCESS.LISP#52 at 8-Jun-88 16:27:09
#10R FILE-SYSTEM#: 
(COMPILER-LET ((*PACKAGE* (PKG-FIND-PACKAGE "FILE-SYSTEM")))
  (COMPILER::PATCH-SOURCE-FILE "SYS: NETWORK; IP-TCP; USER; FTP-ACCESS  "

(undefmethod (ftp-file-stream-mixin :before :plist))

))

; From modified file DJ: L.NETWORK.IP-TCP.USER; FTP-ACCESS.LISP#52 at 8-Jun-88 16:27:38
#10R FILE-SYSTEM#: 
(COMPILER-LET ((*PACKAGE* (PKG-FIND-PACKAGE "FILE-SYSTEM")))
  (COMPILER::PATCH-SOURCE-FILE "SYS: NETWORK; IP-TCP; USER; FTP-ACCESS  "

(defmethod (ftp-file-stream-mixin :plist) (&aux p)
  (or (and (variable-boundp si:property-list) si:property-list)
      ;;Property-list already initialized
      (if (and (null si:current-process) property-list-lock)
	  ;;We are the scheduler updating the wholine and somebody else is getting the property list
	  nil
	(with-lock (property-list-lock)
	  (cond ((not support-plistp)
		 ;;Can't get property list -- either raw-directory list or we've tried and failed.
		 nil)
		((setq support-plistp nil)	;For effect only
		 ;; If we dont set this to NIL then the interaction of the stack of TV:WHO-LINE file streams
		 ;; will cause failure.  Doing the OPEN is ok, and causes a new stream (:Raw-directory-list t)
		 ;; to be seen in the who-line, (which unfortunately *looks* like the present one, but is not)
		 ;; but when that stream is closed it removes itself, causes the previous stream, *us* to be seen,
		 ;; and to be sent yet another :LENGTH message, and we get a recursive call to this code.
		 nil)
		((not (ftp-directory-line-parserp (send host-unit :host)))
		 ;;No parser for this host -- can't get property list
		 nil)
		((setq p (or probe-stream (open truename :direction nil)))
		 ;;We have a probe stream -- copy its property list
		 (setq truename (send p :truename))
		 (setq si:property-list (plist p)))
		(t
		 ;;No probe stream??
		 nil))))))

))

