Fix retry logic. Remove extraneous newlines in logging.
authorGerd Flaig <gefla@gefla-mac-zrh>
Fri, 2 Jan 2009 17:26:48 +0000 (18:26 +0100)
committerGerd Flaig <gefla@gefla-mac-zrh>
Fri, 2 Jan 2009 17:26:48 +0000 (18:26 +0100)
empire.lisp

index 1f2aae423b6724f4d7a42cf171519c80d0cfd91f..34aea1367f279b6a5c6130f00719a420083b3673 100644 (file)
   (handler-case
       (let* ((s (network-stream c))
             (line (read-line s)))
-       (empire-log:info "< ~a~%" line)
+       (empire-log:info "~a: < ~a" c line)
        (multiple-value-bind (message type) (parse-server-line line)
          (let ((handler (lookup-handler type))
                (mode (connection-mode c)))
     (force-output s))
   
 (defmethod send-message ((c connection) message)
-  (let ((s (network-stream c)))
-    (empire-log:info "> ~a~%" message)
-    (let ((sent-p nil)
-         (tries 3))
-      (loop
-        while (and (not sent-p)
-                   (> tries 0))
-        do (handler-case
-               (progn
-                 (raw-send-message s message)
-                 (setf sent-p t))
-             (sb-int:closed-stream-error ()
-               (progn
-                 (decf tries)
-                 (empire-log:info "Connection close - retrying (~a tries left)" tries)
-                 (reconnect c))))))
-    message))
+  (empire-log:info "~a: > ~a" c message)
+  (let ((sent-p nil)
+       (tries 3))
+    (loop
+       while (and (not sent-p)
+                 (> tries 0))
+       do (handler-case
+             (let ((s (network-stream c)))
+               (raw-send-message s message)
+               (setf sent-p t))
+           (sb-int:closed-stream-error ()
+             (progn
+               (decf tries)
+               (empire-log:info "~a: Connection close - retrying (~a tries left)" c tries)
+               (reconnect c))))))
+  message)
 
 (defparameter +special-command-char+ #\;)