solanum-ircd / solanum

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

Delay rehashing until we're not processing events #421

Closed edk0 closed 7 months ago

edk0 commented 8 months ago

Fixes bug/probable regression introduced by 0ab6dbbc651ddd1c26cb7baa6e6cf86890a4abd2

rehash() closes listeners. If we happen to get a single epoll() result that wants to first rehash and then accept a connection, the epoll info will point to a freed rb_fde_t. Other selectors should have similar problems, but we didn't investigate that.

rb_fde_ts are normally batched up and freed outside the event processing, but as of the above commit close_listeners() screws that up by closing pending FDs immediately in order to create new listeners.

I think it might be a bit better to revert this behaviour and simply not close listeners if we are going to open new ones over them, but have opted for the smallest reasonable change I can think of.