Fix relation undefined error.
authorSteve Youngs <steve@emchat.org>
Sun, 20 Jul 2014 06:04:05 +0000 (16:04 +1000)
committerSteve Youngs <steve@emchat.org>
Sun, 20 Jul 2014 06:04:05 +0000 (16:04 +1000)
This error was caused by the scenario of having multiple ICQ clients
(non-EMchat) connected.  If one or more of the other clients cycled its
connection it could cause the HELLO CID to be sent to EMchat, which would
get rather confused seeing as though it wasn't in the middle of logging
in.

To work around this we just force a disconnect.  If the user has saved
their password EMchat will then attempt an auto-reconnect.  After the new
connection is established all is good again.

* emchat-v8.el (emchat-v8-fetch-flap): Disconnect when a bogus
FLAP header comes in.

Signed-off-by: Steve Youngs <steve@emchat.org>
emchat-v8.el

index 078ee30..e70f547 100644 (file)
@@ -2373,7 +2373,17 @@ SPEC is one of
   (unwind-protect
       (let ((bb (emchat-v8-fetch-byte data)))
        (if (not (= bb #x2A))
-           (emchat-v8-debug "Unexpected data while fetching FLAP: %S" bb)
+           ;; According to the spec, this should never ever happen,
+           ;; a FLAP header should ALWAYS begin with #x2A.  However,
+           ;; things can and do get screwy if you have multiple
+           ;; clients connecting and disconnecting independently of
+           ;; each other.  When things do go pear shaped EMchat will
+           ;; disconnect here (and possibly attempt auto-reconnect),
+           ;; and that seems to put things right. --SY.
+           (progn
+             (emchat-v8-debug "Unexpected data while fetching FLAP: %S" bb)
+             (emchat-v8-debug "    Lets play it safe and disconnect")
+             (emchat-do-disconnect 'bugout))
          (let* ((cin (emchat-v8-fetch-byte data))
                 (seq (emchat-v8-fetch-word data))
                 (flen (emchat-v8-fetch-word data))