Skip to content

Commit 65f8ebd

Browse files
trying to fix the notification system
1 parent 1d89906 commit 65f8ebd

File tree

7 files changed

+67
-408
lines changed

7 files changed

+67
-408
lines changed

src/unix/lwt_engine.ml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ let _fake_event = {
3535
node = Lwt_sequence.add_l (Obj.repr ()) (Lwt_sequence.create ());
3636
}
3737

38-
let fake_event = ref _fake_event
39-
4038
(* +-----------------------------------------------------------------+
4139
| Engines |
4240
+-----------------------------------------------------------------+ *)

src/unix/lwt_engine.mli

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ type event
1414
val stop_event : event -> unit
1515
(** [stop_event event] stops the given event. *)
1616

17-
val fake_event : event
18-
(** Event which does nothing when stopped. *)
19-
2017
(** {2 Event loop functions} *)
2118

2219
val iter : bool -> unit

src/unix/lwt_unix.cppo.ml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2201,18 +2201,20 @@ external init_notification : Domain.id -> Unix.file_descr = "lwt_unix_init_notif
22012201
external send_notification : Domain.id -> int -> unit = "lwt_unix_send_notification_stub"
22022202
external recv_notifications : Domain.id -> int array = "lwt_unix_recv_notifications_stub"
22032203

2204-
let handle_notifications domain_id (_ : Lwt_engine.event) =
2204+
let handle_notifications (_ : Lwt_engine.event) =
2205+
let domain_id = Domain.self () in
22052206
Array.iter (call_notification domain_id) (recv_notifications domain_id)
22062207

2207-
let event_notifications = Domain_map.create_protected_map ()
2208+
let event_notifications =
2209+
Domain.DLS.new_key (fun () ->
2210+
let domain_id = Domain.self () in
2211+
Lwt_engine.on_readable (init_notification domain_id) handle_notifications
2212+
)
22082213

22092214
let init_domain () =
22102215
let domain_id = Domain.self () in
22112216
let _ : notifier Notifiers.t = (Domain_map.init notifiers domain_id (fun () -> Notifiers.create 1024)) in
2212-
let _ : Lwt_engine.event = Domain_map.init event_notifications domain_id (fun () ->
2213-
let eventfd = init_notification domain_id in
2214-
Lwt_engine.on_readable eventfd (handle_notifications domain_id))
2215-
in
2217+
let _ : Lwt_engine.event = Domain.DLS.get event_notifications in
22162218
()
22172219

22182220
(* +-----------------------------------------------------------------+
@@ -2316,12 +2318,9 @@ let fork () =
23162318
reset_after_fork ();
23172319
(* Stop the old event for notifications. *)
23182320
let domain_id = Domain.self () in
2319-
(match Domain_map.find event_notifications domain_id with
2320-
| Some event -> Lwt_engine.stop_event event
2321-
| None -> ());
2321+
Lwt_engine.stop_event (Domain.DLS.get event_notifications);
23222322
(* Reinitialise the notification system. *)
2323-
let new_event = Lwt_engine.on_readable (init_notification domain_id) (handle_notifications domain_id) in
2324-
Domain_map.add event_notifications domain_id new_event;
2323+
Domain.DLS.set event_notifications (Lwt_engine.on_readable (init_notification domain_id) handle_notifications);
23252324
(* Collect all pending jobs. *)
23262325
let l = Lwt_sequence.fold_l (fun (_, f) l -> f :: l) jobs [] in
23272326
(* Remove them all. *)

0 commit comments

Comments
 (0)