;;; -*- Mode:Lisp; Readtable:ZL; Package:USER; Base:10; Patch-File:T -*-
;;; Patch file for System version 123.60
;;; Reason:
;;;  Don't :free a host unit when you remove the file stream -- just do it (as always)
;;;  when you close the data connection.  Cerror if you try an ftp-access-operation
;;;  on an unreserved host unit.  Always :setup-control-connection when allocated.
;;; Written 20-Oct-87 15:21:38 by pld at site LMI Cambridge
;;; while running on Jack Flanders from band 2
;;; with Experimental System 123.58, Experimental Local-File 73.0, Experimental FILE-Server 22.0, 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.IP-TCP.USER; FTP-ACCESS.LISP#21 at 20-Oct-87 15:22:32
#10R FILE-SYSTEM#: 
(COMPILER-LET ((*PACKAGE* (PKG-FIND-PACKAGE "FILE-SYSTEM")))
  (COMPILER::PATCH-SOURCE-FILE "SYS: NETWORK; IP-TCP; USER; FTP-ACCESS  "


(defmethod (ftp-access :get-host-unit) (&optional noerror-p)
  ;; change the semantics slightly to both GET and RESERVE a unit.
  (let ((unit (do ((l host-units (cdr l)))
		  ((null l)
		   (send (send self :new-host-unit noerror-p) :reserve))
		(when (send (car l) :reserve)
		  (return (car l))))))
    (send unit :setup-control-connection)
    unit))

))

; From modified file DJ: L.NETWORK.IP-TCP.USER; FTP-ACCESS.LISP#21 at 20-Oct-87 15:22:45
#10R FILE-SYSTEM#: 
(COMPILER-LET ((*PACKAGE* (PKG-FIND-PACKAGE "FILE-SYSTEM")))
  (COMPILER::PATCH-SOURCE-FILE "SYS: NETWORK; IP-TCP; USER; FTP-ACCESS  "


(defun ftp-access-operation (file unit operation &rest args)
  (unless (send unit :reserved-p)
    (cerror "continue" "access operation on unreserved host unit"))
  (or (lexpr-send unit operation args)
      (send unit :ftp-error operation file)))

))

; From modified file DJ: L.NETWORK.IP-TCP.USER; FTP-ACCESS.LISP#21 at 20-Oct-87 15:22:49
#10R FILE-SYSTEM#: 
(COMPILER-LET ((*PACKAGE* (PKG-FIND-PACKAGE "FILE-SYSTEM")))
  (COMPILER::PATCH-SOURCE-FILE "SYS: NETWORK; IP-TCP; USER; FTP-ACCESS  "


(defmethod (ftp-host-unit :remove-file-stream) (the-file-stream)
  (lock-host-unit (self)
    (when (not (eq file-stream the-file-stream))
      (cerror "remove anyway" "removing ~S but current stream is ~S"
	      the-file-stream file-stream))
    (setq file-stream nil)))

))
