solanum-ircd / solanum

An IRCd for unified networks
https://solanum.chat/
GNU General Public License v2.0
216 stars 53 forks source link

MODRESTART/MODRELOAD: Defer reloading more quickly #422

Closed aaronmdjones closed 7 months ago

aaronmdjones commented 7 months ago

Commit 41390bfe5fa3895b8dee fixed a bug whereby the processing of a MODRESTART command could result in a crash. The approach taken in this fix was to defer the reloading of all modules so that the call stack does not contain functions located in modules that are being reloaded. It did this by scheduling a one-shot timer event for 1 second in the future, in the absense of any better deferral mechanism at the time. Timers are processed by the event loop, which is core to IRCd and cannot be reloaded.

Commit 59ea3c6753e80d051b20 introduced a mechanism to defer the execution of a function until all events have been processed by the event loop, in order to fix a REHASH bug that could result in a crash due to closing and reopening listener sockets with a pending socket connection event to process after the REHASH was completed.

Rework commit 41390bfe5fa3895b8dee to use the new deferral mechanism introduced by commit 59ea3c6753e80d051b20 and do the same for module reloads.