src/irc_log.c
changeset 112 10ada0d1c7d7
parent 110 43e9a7984955
equal deleted inserted replaced
111:5a1ebffca81a 112:10ada0d1c7d7
   478     struct irc_log_chan *chan_ctx;
   478     struct irc_log_chan *chan_ctx;
   479 
   479 
   480     // update our state to mark ourselves as unloading
   480     // update our state to mark ourselves as unloading
   481     ctx->unloading = true;
   481     ctx->unloading = true;
   482     ctx->module = module;
   482     ctx->module = module;
   483 
   483     
   484     // stop logging each channel
   484     if (TAILQ_EMPTY(&ctx->channels)) {
   485     TAILQ_FOREACH(chan_ctx, &ctx->channels, ctx_channels) {
   485         // nothing to do, unloaded now
   486         irc_log_chan_stop(chan_ctx);
   486         module_unloaded(module);
       
   487 
       
   488     } else {
       
   489         // stop logging each channel
       
   490         TAILQ_FOREACH(chan_ctx, &ctx->channels, ctx_channels) {
       
   491             irc_log_chan_stop(chan_ctx);
       
   492         }
       
   493 
       
   494         // once they have all stopped, we will be unloaded
   487     }
   495     }
   488     
   496 
   489     // wait for all the channels to be stopped, which will call irc_log_stopped
   497     // wait for all the channels to be stopped, which will call irc_log_stopped
   490     return SUCCESS;
   498     return SUCCESS;
   491 }
   499 }
   492 
   500 
   493 /**
   501 /**
   494  * We can safely destroy the evsql instance from here, since we're outside of any callbacks from this module
   502  * We can safely destroy the evsql instance from here, since we're outside of any callbacks from this module.
       
   503  *
       
   504  * Note that we might not have had any of the config options called...
   495  */
   505  */
   496 static void irc_log_destroy (void *_ctx)
   506 static void irc_log_destroy (void *_ctx)
   497 {
   507 {
   498     struct irc_log_ctx *ctx = _ctx;
   508     struct irc_log_ctx *ctx = _ctx;
   499 
   509 
   500     log_debug("destroying the irc_log_ctx");
   510     log_debug("destroying the irc_log_ctx");
   501 
   511 
   502     // destroy the evsql instance
   512     if (ctx->db)
   503     evsql_destroy(ctx->db);
   513         // destroy the evsql instance
       
   514         evsql_destroy(ctx->db);
   504 
   515 
   505     // ...no more
   516     // ...no more
   506     free(ctx);
   517     free(ctx);
   507 }
   518 }
   508 
   519