Changeset 12188

Jun 3, 2009, 7:21:21 PM (11 years ago)

swank loading works; SLIME/swank connections work; UI control of swank load and startup works. Likely need additional error-handlng.

4 edited


  • trunk/source/cocoa-ide/ide-contents/Resources/English.lproj/preferences.nib/classes.nib

    r12183 r12188  
    3535                                <key>listenerTabViewItem</key>
    3636                                <string>id</string>
    37                                 <key>swankPortField</key>
    38                                 <string>id</string>
    39                                 <key>swankProtocolLabel</key>
     37                                <key>swankListenerPort</key>
    4038                                <string>id</string>
    4139                                <key>tabView</key>
  • trunk/source/cocoa-ide/preferences.lisp

    r12183 r12188  
    144144  (declare (ignore sender))
    145145  (unless (or *ccl-swank-active-p*
    146               (try-starting-swank :force t))
     146              (maybe-start-swank-listener :override-user-preference t))
    147147    (alert-window :message "Unable to start the Swank server.")))
  • trunk/source/cocoa-ide/swank-listener.lisp

    r12187 r12188  
    5959   (let* ((defaults (handler-case (#/values (#/sharedUserDefaultsController ns:ns-user-defaults-controller))
    6060                     (serious-condition (c)
    61                        (progn (log-debug "~%ERROR: Unable to get preferences from the Shared User Defaults Controller")
     61                       (progn (log-debug "~%ERROR: Unable to get preferences from the Shared User Defaults Controller: ~a" c)
    6262                              nil))))
    6363         (start-swank-pref (if (and defaults (not (%null-ptr-p defaults)))
    101101(defstruct (swank-status (:conc-name swank-))
    102102  (active? nil :read-only t)
     103  (message nil :read-only t)
    103104  (requested-loader nil :read-only t)
    104105  (requested-port nil :read-only t))
    131132  (handler-case (progn
    132133                  (load path)
    133                   ;; TODO: find a workaround that doesn't require swank to be loaded
    134                   ;;(swank:create-server :port requested-port :dont-close t)
    135                   (make-swank-status :active? t :requested-loader path :requested-port requested-port))
     134                  (let ((swank-loader-package (find-package :swank-loader)))
     135                    (if swank-loader-package
     136                        ;; swank loaded. start the server
     137                        (progn
     138                          (funcall (intern "LOAD-SWANK" swank-loader-package))
     139                          (funcall (intern "CREATE-SERVER" (find-package :swank)) :port requested-port :dont-close t)
     140                          (make-swank-status :active? t :requested-loader path :requested-port requested-port))
     141                        ;; swank failed to load. return failure status
     142                        (make-swank-status :active? nil :message "swank load failed" :requested-loader path :requested-port requested-port))))
    136143    (ccl::socket-creation-error (e) (log-debug "Unable to start a swank server on port: ~A; ~A"
    137144                                               requested-port e)
    138                                 (make-swank-status :active? nil :requested-loader path :requested-port requested-port))
     145                                (make-swank-status :active? nil :message "socket-creation error"
     146                                                   :requested-loader path :requested-port requested-port))
    139147    (serious-condition (e) (log-debug "There was a problem creating the swank server on port ~A: ~A"
    140148                                      requested-port e)
    141                        (make-swank-status :active? nil :requested-loader path :requested-port requested-port))))
     149                       (make-swank-status :active? nil :message "error loading or starting swank"
     150                                          :requested-loader path :requested-port requested-port))))
    143152(defun swank-ready? (status)
    162171;;; if it fails, it returns a CONDITION object
    163172(defun start-swank-listener (&optional (port *default-swank-listener-port*))
    164   (handler-case (with-open-socket (sock :type :stream :connect :passive :local-port port :reuse-address t :auto-close t)
    165                   (loop
    166                                              (format t "~%swank listener loop...")
    167                                              (force-output)
    168                                              (let* ((client-sock (accept-connection sock))
    169                                                     (status (handle-swank-client client-sock)))
    170                                                (send-swank-response client-sock status))))
     173  (handler-case
     174      (process-run-function "Swank Listener"
     175                            #'(lambda ()
     176                                (with-open-socket (sock :type :stream :connect :passive :local-port port :reuse-address t :auto-close t)
     177                                  (let* ((client-sock (accept-connection sock))
     178                                         (status (handle-swank-client client-sock)))
     179                                    (send-swank-response client-sock status)))))
    171180    (ccl::socket-creation-error (c) (nslog-condition c "Unable to create a socket for the swank-listener: ") c)
    172     (ccl::socket-error (c) (nslog-condition c "Swank-listener failed trying to accept a client conection: ") c)
    173     (serious-condition (c) (nslog-condition c "Error in the swank-listener:") c)))
     181    (ccl::socket-error (c) (nslog-condition c "Swank-listener failed trying to accept a client connection: ") c)
     182    (serious-condition (c) (nslog-condition c "Error starting in the swank-listener:") c)))
    175184;;; maybe-start-swank-listener
    177186;;; checks whether to start the ccl swank listener, and starts it if
    178187;;; warranted.
    179 (defun maybe-start-swank-listener ()
     188(defun maybe-start-swank-listener (&key (override-user-preference nil))
    180189  (unless *ccl-swank-listener-active-p*
    181190    ;; try to determine the user preferences concerning the
    183192    ;; should be started. If the user says start it, and we can
    184193    ;; determine a valid port for it, start it up
    185     #|
    186     (let* ((start-swank-listener? (preference-start-swank-listener?))
     194    (let* ((start-swank-listener? (or (preference-start-swank-listener?) override-user-preference))
    187195           (swank-listener-port (or (preference-swank-listener-port) *default-swank-listener-port*)))
    188196      (if (and start-swank-listener? swank-listener-port)
    208216            (setf *active-gui-swank-listener-port* nil)
    209217            (setf *ccl-swank-listener-active-p* nil)
    210             nil)))|#
    211 ))
     218            nil)))))
    213220(provide :swank-listener)
Note: See TracChangeset for help on using the changeset viewer.