--- a/src/irc_net.c Thu Mar 12 22:50:08 2009 +0200
+++ b/src/irc_net.c Thu Mar 12 23:05:54 2009 +0200
@@ -4,34 +4,57 @@
#include <stdlib.h>
#include <string.h>
+/**
+ * Something happaned which caused our irc_conn to fail. Destroy it, and recover. XXX: somehow
+ */
+static void irc_net_error (struct irc_net *net, struct error_info *err)
+{
+ struct irc_chan *chan = NULL;
+
+ // log an error
+ log_err_info(err, "irc_conn failed");
+
+ // destroy connection and set NULL
+ irc_conn_destroy(net->conn);
+ net->conn = NULL;
+
+ // update channel state
+ TAILQ_FOREACH(chan, &net->channels, node) {
+ // XXX: notify channel somehow
+ }
+
+ // XXX: reconnect?
+}
+
+/**
+ * Our irc_conn has registered. Join our channels
+ */
static void irc_net_conn_registered (struct irc_conn *conn, void *arg)
{
struct irc_net *net = arg;
struct irc_chan *chan = NULL;
- err_t err;
+ struct error_info err;
(void) conn;
// join our channels
TAILQ_FOREACH(chan, &net->channels, node) {
- if ((err = irc_chan_join(chan)))
- // XXX: fuck...
- FATAL_ERR(err, "irc_chan_join failed");
+ if ((ERROR_CODE(&err) = irc_chan_join(chan)))
+ // XXX: this should be some kind of irc_chan_error instead
+ irc_net_error(net, &err);
}
}
+/**
+ * Our irc_conn has spontaneously failed, destroy it
+ */
static void irc_net_conn_error (struct irc_conn *conn, struct error_info *err, void *arg)
{
struct irc_net *net = arg;
-
- // log an error
- log_err_info(err, "irc_conn failed");
- // destroy and set NULL
- irc_conn_destroy(conn);
- net->conn = NULL;
-
- // XXX: reconnect?
+ (void) conn;
+
+ irc_net_error(net, err);
}
/**
@@ -204,6 +227,5 @@
// no such channel
return NULL;
-
}