--- a/src/irc_log.c Thu Apr 02 02:55:32 2009 +0300
+++ b/src/irc_log.c Thu Apr 02 02:55:59 2009 +0300
@@ -480,18 +480,28 @@
// update our state to mark ourselves as unloading
ctx->unloading = true;
ctx->module = module;
+
+ if (TAILQ_EMPTY(&ctx->channels)) {
+ // nothing to do, unloaded now
+ module_unloaded(module);
- // stop logging each channel
- TAILQ_FOREACH(chan_ctx, &ctx->channels, ctx_channels) {
- irc_log_chan_stop(chan_ctx);
+ } else {
+ // stop logging each channel
+ TAILQ_FOREACH(chan_ctx, &ctx->channels, ctx_channels) {
+ irc_log_chan_stop(chan_ctx);
+ }
+
+ // once they have all stopped, we will be unloaded
}
-
+
// wait for all the channels to be stopped, which will call irc_log_stopped
return SUCCESS;
}
/**
- * We can safely destroy the evsql instance from here, since we're outside of any callbacks from this module
+ * We can safely destroy the evsql instance from here, since we're outside of any callbacks from this module.
+ *
+ * Note that we might not have had any of the config options called...
*/
static void irc_log_destroy (void *_ctx)
{
@@ -499,8 +509,9 @@
log_debug("destroying the irc_log_ctx");
- // destroy the evsql instance
- evsql_destroy(ctx->db);
+ if (ctx->db)
+ // destroy the evsql instance
+ evsql_destroy(ctx->db);
// ...no more
free(ctx);