Skip to content

Commit

Permalink
module.c: Rewrite autoloading using a linked list.
Browse files Browse the repository at this point in the history
This largely rewrites the module traversal logic of the module autoloading
that occurs at BBS startup. Previously, this used a set of string lists
to keep track of modules that should be preloaded, not loaded, required,
etc. Over time, this became very clunky and inefficient, and didn't allow
capturing relationships involving multi-layer dependencies at all.

Instead of this, we now use a single (doubly) linked list so that the
modules can be ordered correctly prior to actually autoloading them.
This also reduces the number of traversals order all and is more
efficient. Some logging has also been cleaned up to be less cluttered
and more usable for the user.

LBBS-2 #close
  • Loading branch information
InterLinked1 committed Dec 23, 2024
1 parent bcbb2b1 commit fb59950
Show file tree
Hide file tree
Showing 8 changed files with 1,531 additions and 208 deletions.
2 changes: 1 addition & 1 deletion bbs/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1077,7 +1077,7 @@ static int check_menus(void)
RWLIST_UNLOCK(&menu->menuitems);
if (!egress_possible) {
/* This will strand any users that access this menu */
bbs_warning("Menu %s contains no way to exit or return from it\n", menu->name);
bbs_warning("Menu '%s' contains no way to exit or return from it\n", menu->name);
}
}
RWLIST_UNLOCK(&menus);
Expand Down
525 changes: 336 additions & 189 deletions bbs/module.c

Large diffs are not rendered by default.

31 changes: 17 additions & 14 deletions configs/modules.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,24 @@ autoload=yes ; By default, all modules are loaded automatically on startup.
; You can explicitly load only the modules you want by using autoload=no.

[modules]
; You can specify modules to preload, for module dependencies that must be met before dependent modules load.
; For all operations here, the order of preload, load, and noload does not matter (and should not be relied upon).
; require is equivalent to load, but will abort startup if the module fails to load.
; To preload and require a module, specify both directives.
; For all operations here, the order of preload, require, load, and noload does not matter (and should not be relied upon).
; require is equivalent to load, but will abort BBS startup if the module fails to load.
; load will always attempt to load a specific module, and noload will always prevent loading a specific module,
; independent of the autoload setting.
; The 'preload' setting is similar to 'load' and will move it earlier in the loading sequence. Normally, this does not need to be specified.

; You can specify modules to automatically load or not load at startup here.
; You MUST specify the .so extension in modules.conf (but optional in sysop console)
; Modules can always be explicitly loaded from the sysop console
; using /load <modname>, even if they were not autoloaded.

; Library modules
preload = io_compress.so
preload = io_tls.so
preload = mod_lmdb.so
preload = mod_mysql.so ; mod_auth_mysql.so and mod_chanserv.so depend on this module
preload = io_tls.so ; Support for TLS. This module is always preloaded, if loaded, so load= would also technically work.
; The io modules are not "hard" dependencies for anything and will not be autoloaded if needed,
; therefore be sure to explicitly load (or preload) it if autoload=no.
load = io_compress.so
load = mod_lmdb.so
load = mod_mysql.so ; mod_auth_mysql.so and mod_chanserv.so depend on this module

; Basic doors
load = door_usermgmt.so
Expand Down Expand Up @@ -50,16 +53,16 @@ load = door_utilities.so
load = door_ibbs.so

; IRC modules
preload = net_irc.so ; mod_discord.so, mod_chanserv.so, and mod_irc_relay.so depend on this module
load = net_irc.so ; mod_discord.so, mod_chanserv.so, and mod_irc_relay.so depend on this module
load = mod_irc_client.so ; mod_irc_relay.so depends on this module
load = mod_irc_relay.so
load = mod_chanserv.so
load = mod_discord.so
load = mod_slack.so

; Email modules
preload = mod_mail.so
preload = mod_mimeparse.so
load = mod_mail.so
load = mod_mimeparse.so
load = mod_mail_trash.so
load = mod_mail_events.so
load = mod_mailscript.so
Expand All @@ -84,7 +87,7 @@ load = net_sieve.so
load = net_smtp.so

; Web server
preload = mod_http.so
load = mod_http.so
load = mod_http_proxy.so
load = net_http.so
load = net_ws.so
Expand All @@ -102,8 +105,8 @@ load = net_gopher.so
load = net_msp.so

; Asterisk modules
preload = mod_ncurses.so
preload = mod_asterisk_ami.so
load = mod_ncurses.so
load = mod_asterisk_ami.so
load = mod_asterisk_queues.so
load = mod_operator.so

Expand Down
Loading

0 comments on commit fb59950

Please sign in to comment.