Date: Wed, 2 Aug 2017 13:13:11 +0300 From: Andriy Gapon <avg@FreeBSD.org> To: FreeBSD Hackers <freebsd-hackers@FreeBSD.org>, FreeBSD Current <freebsd-current@FreeBSD.org> Subject: order of executing MOD_LOAD and registering module sysctl-s Message-ID: <62e7ab4d-8956-545e-b204-4fb63cfe5fbf@FreeBSD.org>
next in thread | raw e-mail | index | archive | help
As far as I understand a module initialization routine is executed via the sysinit mechanism. Specifically, module_register_init is set up as the sysinit function for every module and it calls MOD_EVENT(mod, MOD_LOAD) to invoke the module event handler. In linker_load_file() I see the following code: linker_file_register_sysctls(lf); linker_file_sysinit(lf); I think that this means that any statically declared sysctl-s in the module would be registered before the module receives the MOD_LOAD event. It's possible that some of the sysctl-s could have procedures as handlers and they might access data that is supposed to be initialized by the module event handler. So, for example, running sysctl -a at just the right moment during the loading of a module might end up in an expected behavior (including a crash). Is my interpretation of how the code works correct? Can the order of linker_file_sysinit and linker_file_register_sysctls be changed without a great risk? Thank you! P.S. The same applies to: linker_file_sysuninit(file); linker_file_unregister_sysctls(file); -- Andriy Gapon
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?62e7ab4d-8956-545e-b204-4fb63cfe5fbf>