Summary

irc: reconnecting due to server-side EOF broken

Metadata

Description

With the irc egg in version 1.9.5, the reconnect handling in `irc:wait` is broken:

When I use `/kill testuser` on the server, the connection gets shut down by the server and `(read-input con)` returns an EOF object.

However, `irc:wait` does not check for an EOF object, it only uses `condition-case` to catch an `irc/eof` error. This is useless, because `(read-input con)` doesn’t `signal` an EOF error, it merely returns an EOF object.

Therefore, `irc:wait` will pass this EOF object to `parse-reply`, which does check for EOF objects and calls `(eof-error con)`. Since that is outside of the `condition-case`, this error aborts the program flow instead of triggering the reconnect behavior.

Here is a naive fix for the problem:

 (define (irc:wait con)
   (unless (irc:connection-connected? con)
     (error "not connected" con) )
   (parse-reply
    (let loop ()
      (condition-case
        (let ((line (read-input con)))
         (when (eof-object? line)
           (eof-error con))
         line)
        (ex (exn net timeout)
            ;(print "\n*** timeout - reconnecting")
            (cond ((irc:connection-reconnect? con)
                   (irc:reconnect con)
                   (loop))
                  (else (abort ex))))
        (ex (irc/eof)
            (print "\n*** EOF - reconnecting")
            (cond ((irc:connection-reconnect? con)
                   (irc:reconnect con)
                   (loop))
                  (else (abort ex))))))
    con))

PS: Forgive me if my terminology is wrong. I’m still new ;-).

Changes and comments

[2012-09-10 21:27:20 UTC] felix changed status from new to closed

[2012-09-10 21:27:20 UTC] felix set resolution to fixed

[2012-09-10 21:27:20 UTC] felix wrote:

Thanks for this fix, Michael. I have applied it and tagged irc 1.9.6.