send QUIT to all active connections

This commit is contained in:
tali 2024-02-01 19:04:24 -05:00
parent 04478ffa0e
commit aed3089995
2 changed files with 18 additions and 3 deletions

View File

@ -28,6 +28,16 @@ let find_chan t name =
let whowas t nick =
Cache.find_all t.whowas (string_ci nick)
let nuke t =
begin
Hashtbl.iter (fun _ u -> Dllist.reset u.membership) t.users;
Hashtbl.iter (fun _ c -> Dllist.reset c.members) t.channels;
Hashtbl.clear t.users;
Hashtbl.clear t.channels;
t.lusers <- 0;
t.luserchannels <- 0;
end
let relay ~(from : user) (msg : Msg.t) tgts =
let msg =
if msg.prefix = No_prefix then

View File

@ -200,8 +200,13 @@ let run {
in
notify `stopping;
(* TODO: send QUIT to all connections *)
info (fun m -> m "shutting down");
Lwt_unix.close server
let* () = Lwt_unix.close server in
Router.nuke router;
Wheel.iter (fun conn -> Connection.close conn ~reason:"Server shutting down")
(* ping wheel should contain every active connection *)
ping_wheel;
(* give some time for the messages to send *)
Lwt_unix.sleep 0.5