;;; -*- Mode:Lisp; Readtable:CL; Package:USER; Base:10; Patch-File:T -*-
;;; Patch file for System version 123.121
;;; Reason:
;;;  Generalize net:move-initialization.  Make sure the (net:deconfigure) initialization appears before
;;;  the (flip level 2) initialization on the :before-cold list.  Give the user the option of deconfiguring
;;;  the network before a (full-gc).  If yes, reconfigure the network afterwards.
;;; Written 23-Nov-87 13:22:15 by pld at site Gigamos Cambridge
;;; while running on Jack Flanders from band 2
;;; with Experimental System 123.120, Experimental Local-File 73.2, 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.KERNEL; CONFIGURE.LISP#84 at 23-Nov-87 13:22:21
#10R NETWORK#: 
(COMPILER-LET ((*PACKAGE* (GLOBAL:PKG-FIND-PACKAGE "NETWORK")))
  (COMPILER::PATCH-SOURCE-FILE "SYS: NETWORK; KERNEL; CONFIGURE  "

(defun move-initialization (initialization-list first-name second-name)
  (do* ((first nil)
	(list initialization-list (cdr list))
	(next (second list) (second list)))
       ((null list))
    (cond ((string-equal first-name (car next))
	   (setq first list))
	  ((string-equal second-name (car next))
	   (when first
	     (setf (cdr list) (cddr list))	;Splice out second initialization
	     (setf (cdr first) (nconc (ncons next) (cdr first))))
	   (return))
	  (t))))

))

; From modified file DJ: L.NETWORK.KERNEL; CONFIGURE.LISP#84 at 23-Nov-87 13:22:31
#10R NETWORK#: 
(COMPILER-LET ((*PACKAGE* (GLOBAL:PKG-FIND-PACKAGE "NETWORK")))
  (COMPILER::PATCH-SOURCE-FILE "SYS: NETWORK; KERNEL; CONFIGURE  "

(add-initialization "Move network deconfiguration initialization"
		    '(move-initialization si:before-cold-initialization-list "Flip Level 2" "Deconfigure Network System")
		    '(:once))

))

; From modified file DJ: L.NETWORK.KERNEL; CONFIGURE.LISP#84 at 23-Nov-87 13:22:35
#10R NETWORK#: 
(COMPILER-LET ((*PACKAGE* (GLOBAL:PKG-FIND-PACKAGE "NETWORK")))
  (COMPILER::PATCH-SOURCE-FILE "SYS: NETWORK; KERNEL; CONFIGURE  "

(defvar *network-deconfigured-before-gc* nil)

))

; From modified file DJ: L.NETWORK.KERNEL; CONFIGURE.LISP#84 at 23-Nov-87 13:22:39
#10R NETWORK#: 
(COMPILER-LET ((*PACKAGE* (GLOBAL:PKG-FIND-PACKAGE "NETWORK")))
  (COMPILER::PATCH-SOURCE-FILE "SYS: NETWORK; KERNEL; CONFIGURE  "

(defun maybe-deconfigure-network ()
  (setq *network-deconfigured-before-gc* nil)
  (when (and (boundp '*loopback-interface*)
	     *loopback-interface*
	     (ni-enabled *loopback-interface*))
    (format *query-io* "~&    Deconfiguring the network will allow garbage collection to reclaim network objects.~%")
    (when (global:with-timeout ((* 30 60.) (progn (write-string "Yes (after timeout)" *query-io*) t))
	    (yes-or-no-p "        Deconfigure network (Yes after thirty seconds) ? "))
      (setq *network-deconfigured-before-gc* t)
      (net:deconfigure))))

))

; From modified file DJ: L.NETWORK.KERNEL; CONFIGURE.LISP#84 at 23-Nov-87 13:22:45
#10R NETWORK#: 
(COMPILER-LET ((*PACKAGE* (GLOBAL:PKG-FIND-PACKAGE "NETWORK")))
  (COMPILER::PATCH-SOURCE-FILE "SYS: NETWORK; KERNEL; CONFIGURE  "

(add-initialization "Deconfigure Network" '(maybe-deconfigure-network) '(:full-gc))

))

; From modified file DJ: L.NETWORK.KERNEL; CONFIGURE.LISP#84 at 23-Nov-87 13:22:55
#10R NETWORK#: 
(COMPILER-LET ((*PACKAGE* (GLOBAL:PKG-FIND-PACKAGE "NETWORK")))
  (COMPILER::PATCH-SOURCE-FILE "SYS: NETWORK; KERNEL; CONFIGURE  "

(add-initialization "Reconfigure Network" '(when *network-deconfigured-before-gc* (net:configure)) '(:after-full-gc))

))
