at main
1 folder
60 files
Tidy up module loading code
The existing code had several defects:
- Core module file names were hardcoded, while autoloaded non-
core module filenames were not. Code that loaded core modules
had a different but in some places duplicated structure to the
code that loaded autoloaded modules.
- Module loading for autoloaded modules happened in dentry
order, making it unpredictable from one server to the next, or
even across instances of `make install` on the same server.
- Module loading for autoloaded modules did not verify that the
dentry was a file before trying to load it.
- An IRCd start (or a conftest) only printed lines about loading
modules mentioned in the configuration file.
- The configuration file was parsed before loading core and
autoloaded modules, meaning any modules specified in the
configuration file would be loaded first.
- Once a module was loaded, it was added to the head of the
module list, making MODLIST show them in reverse loaded order
(newest (re)loaded modules at the top of the list).
These are addressed as follows:
- We now scan the core and autoload module directories and use
this to determine which modules to load.
- We now sort the dentries according to their filename before
iterating them to load them, making module load order finally
deterministic.
- We now test if a dentry is actually a file before trying to
load it.
- We now print a message to the console (if running in
foreground or conftest mode) when loading any module,
including core and autoloaded modules.
- The message printed to the console now has the IRCd module
directory prefix stripped from it if it matches.
- The configuration file is now parsed after loading core and
autoload modules.
- The modules are added to the module list in the order that
they are loaded. This now makes MODLIST show the order that
modules were (re)loaded in.
Modifications to two modules are part of this effort:
- The autoload module `m_alias` relied upon the alias dict not
being NULL when loaded, but this is only the case after the
configuration file has been parsed.
The module already had a "rehash" hook to destroy all existing
aliases and create new ones, so we can just make the module do
nothing on load (remove its modinit function) and change it to
use the "conf_read_end" hook instead of the "rehash" hook, and
it will still create aliases after the configuration file is
subsequently parsed.
With this modification, there are now no in-tree consumers of
the "rehash" hook.
- The autoload module `m_services` iterated `service_list` upon
loading it, which will now be empty (a no-op) since the module
is loaded before configuration file is parsed.
This module too handles the configuration file being parsed
with a "conf_read_end" hook and takes the appropriate action,
so we can just remove this code from its modinit function.
All other modules' modinit functions have been audited for
behaviour like this; there was nothing of note.
Clean up include/stdinc.h and librb/include/rb_lib.h
- Unconditionally require stdbool.h in IRCd
We are a C99 project anyway (configure.ac and meson.build both
require a C99 compiler), so this header will always be present
This removes the awful hack defining bool, true, and false in
its absense, which was creating build errors when using meson,
because meson.build did not set the HAVE_STDBOOL_H macro
- Modernise definition of alloca(3) according to GNU guidance
This was in both librb and IRCd, while it only needs to be in
the former
- Fix missing endianness check in librb/meson.build
IRCd and librb both use the WORDS_BIGENDIAN macro, which was
only being set by their configure.ac (with the AC_C_BIGENDIAN
M4 macro)
Since IRCd's stdinc.h includes librb's rb_lib.h, which then
includes librb's librb-config.h, which would have the macro
defined there, we only need to check for it in librb, so we
can remove the endianness check from IRCd's configure.ac and
don't need to add it to IRCd's meson.build
- Use __has_attribute to detect whether compiler attributes are
available
This is supported by gcc (5+), clang (2.9+), and ICC (17+)
- Add a __noreturn macro for __attribute__((__noreturn__)) and
adjust the codebase to use that
- Remove inclusion of headers that are only used by librb
- Remove inclusion of headers that are included in rb_lib.h
because stdinc.h includes rb_lib.h anyway
- Remove the checks for headers and functions from the IRCd
configure.ac and meson.build that are only used by librb
- Alphabetise checks for headers and functions (by the name of
the macro they define) in the meson.build files
- Use check_header() instead of has_header() in meson to see if
it is actually possible to compile code using the header
- Remove dead code using srand48(3) which has never been
compiled because neither build system has ever set the
HAVE_SRAND48 macro and the surrounding code makes no use of
this libc RNG
- Remove the TLS defines from IRCd's meson.build because librb's
meson.build already defines them and IRCd pulls those in
Clean up include/stdinc.h and librb/include/rb_lib.h
- Unconditionally require stdbool.h in IRCd
We are a C99 project anyway (configure.ac and meson.build both
require a C99 compiler), so this header will always be present
This removes the awful hack defining bool, true, and false in
its absense, which was creating build errors when using meson,
because meson.build did not set the HAVE_STDBOOL_H macro
- Modernise definition of alloca(3) according to GNU guidance
This was in both librb and IRCd, while it only needs to be in
the former
- Fix missing endianness check in librb/meson.build
IRCd and librb both use the WORDS_BIGENDIAN macro, which was
only being set by their configure.ac (with the AC_C_BIGENDIAN
M4 macro)
Since IRCd's stdinc.h includes librb's rb_lib.h, which then
includes librb's librb-config.h, which would have the macro
defined there, we only need to check for it in librb, so we
can remove the endianness check from IRCd's configure.ac and
don't need to add it to IRCd's meson.build
- Use __has_attribute to detect whether compiler attributes are
available
This is supported by gcc (5+), clang (2.9+), and ICC (17+)
- Add a __noreturn macro for __attribute__((__noreturn__)) and
adjust the codebase to use that
- Remove inclusion of headers that are only used by librb
- Remove inclusion of headers that are included in rb_lib.h
because stdinc.h includes rb_lib.h anyway
- Remove the checks for headers and functions from the IRCd
configure.ac and meson.build that are only used by librb
- Alphabetise checks for headers and functions (by the name of
the macro they define) in the meson.build files
- Use check_header() instead of has_header() in meson to see if
it is actually possible to compile code using the header
- Remove dead code using srand48(3) which has never been
compiled because neither build system has ever set the
HAVE_SRAND48 macro and the surrounding code makes no use of
this libc RNG
- Remove the TLS defines from IRCd's meson.build because librb's
meson.build already defines them and IRCd pulls those in
Clean up include/stdinc.h and librb/include/rb_lib.h
- Unconditionally require stdbool.h in IRCd
We are a C99 project anyway (configure.ac and meson.build both
require a C99 compiler), so this header will always be present
This removes the awful hack defining bool, true, and false in
its absense, which was creating build errors when using meson,
because meson.build did not set the HAVE_STDBOOL_H macro
- Modernise definition of alloca(3) according to GNU guidance
This was in both librb and IRCd, while it only needs to be in
the former
- Fix missing endianness check in librb/meson.build
IRCd and librb both use the WORDS_BIGENDIAN macro, which was
only being set by their configure.ac (with the AC_C_BIGENDIAN
M4 macro)
Since IRCd's stdinc.h includes librb's rb_lib.h, which then
includes librb's librb-config.h, which would have the macro
defined there, we only need to check for it in librb, so we
can remove the endianness check from IRCd's configure.ac and
don't need to add it to IRCd's meson.build
- Use __has_attribute to detect whether compiler attributes are
available
This is supported by gcc (5+), clang (2.9+), and ICC (17+)
- Add a __noreturn macro for __attribute__((__noreturn__)) and
adjust the codebase to use that
- Remove inclusion of headers that are only used by librb
- Remove inclusion of headers that are included in rb_lib.h
because stdinc.h includes rb_lib.h anyway
- Remove the checks for headers and functions from the IRCd
configure.ac and meson.build that are only used by librb
- Alphabetise checks for headers and functions (by the name of
the macro they define) in the meson.build files
- Use check_header() instead of has_header() in meson to see if
it is actually possible to compile code using the header
- Remove dead code using srand48(3) which has never been
compiled because neither build system has ever set the
HAVE_SRAND48 macro and the surrounding code makes no use of
this libc RNG
- Remove the TLS defines from IRCd's meson.build because librb's
meson.build already defines them and IRCd pulls those in
Clean up include/stdinc.h and librb/include/rb_lib.h
- Unconditionally require stdbool.h in IRCd
We are a C99 project anyway (configure.ac and meson.build both
require a C99 compiler), so this header will always be present
This removes the awful hack defining bool, true, and false in
its absense, which was creating build errors when using meson,
because meson.build did not set the HAVE_STDBOOL_H macro
- Modernise definition of alloca(3) according to GNU guidance
This was in both librb and IRCd, while it only needs to be in
the former
- Fix missing endianness check in librb/meson.build
IRCd and librb both use the WORDS_BIGENDIAN macro, which was
only being set by their configure.ac (with the AC_C_BIGENDIAN
M4 macro)
Since IRCd's stdinc.h includes librb's rb_lib.h, which then
includes librb's librb-config.h, which would have the macro
defined there, we only need to check for it in librb, so we
can remove the endianness check from IRCd's configure.ac and
don't need to add it to IRCd's meson.build
- Use __has_attribute to detect whether compiler attributes are
available
This is supported by gcc (5+), clang (2.9+), and ICC (17+)
- Add a __noreturn macro for __attribute__((__noreturn__)) and
adjust the codebase to use that
- Remove inclusion of headers that are only used by librb
- Remove inclusion of headers that are included in rb_lib.h
because stdinc.h includes rb_lib.h anyway
- Remove the checks for headers and functions from the IRCd
configure.ac and meson.build that are only used by librb
- Alphabetise checks for headers and functions (by the name of
the macro they define) in the meson.build files
- Use check_header() instead of has_header() in meson to see if
it is actually possible to compile code using the header
- Remove dead code using srand48(3) which has never been
compiled because neither build system has ever set the
HAVE_SRAND48 macro and the surrounding code makes no use of
this libc RNG
- Remove the TLS defines from IRCd's meson.build because librb's
meson.build already defines them and IRCd pulls those in