Skip to content

Commit fcfd4d5

Browse files
committed
replace lwt.wakeup by lwt.wakeup_later
1 parent 7228a05 commit fcfd4d5

8 files changed

Lines changed: 15 additions & 15 deletions

File tree

src/common/js/ezLwtSys.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
let run = Lwt.async
1212
let sleep d =
1313
let t, w = Lwt.task () in
14-
let id = Js_of_ocaml.Dom_html.setTimeout (Lwt.wakeup w) (d *. 1000.) in
14+
let id = Js_of_ocaml.Dom_html.setTimeout (Lwt.wakeup_later w) (d *. 1000.) in
1515
Lwt.on_cancel t (fun () -> Js_of_ocaml.Dom_html.clearTimeout id);
1616
t

src/request/js/nodejs/ezNodeJS_lwt.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ open Nodejs_common
1212

1313
let to_lwt f =
1414
let w, n = Lwt.wait () in
15-
f (Lwt.wakeup n);
15+
f (Lwt.wakeup_later n);
1616
w
1717

1818
module Interface = struct

src/request/unix/httpun/httpun_client.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ let perform ?msg ?meth ?content ?content_type ?(headers=[]) ?timeout handler url
130130
Option.fold ~none:[] ~some:(fun c -> [ "content-length", string_of_int (String.length c)]) content @
131131
Option.fold ~none:[] ~some:(fun c -> [ "content-type", c]) content_type in
132132
let req = Request.create ~headers meth path in
133-
let error_handler = error_handler (Lwt.wakeup notify) in
134-
let response_handler = handler (Lwt.wakeup notify) in
133+
let error_handler = error_handler (Lwt.wakeup_later notify) in
134+
let response_handler = handler (Lwt.wakeup_later notify) in
135135
let>? body =
136136
Lwt.catch (fun () ->
137137
if scheme = "https" then

src/server/server_common.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ let establish_server_with_client_socket
145145
let read_body ~read body =
146146
let w, n = Lwt.wait () in
147147
let b = Buffer.create 100 in
148-
let on_eof () = Lwt.wakeup n (Buffer.contents b) in
148+
let on_eof () = Lwt.wakeup_later n (Buffer.contents b) in
149149
let rec on_read bs ~off ~len =
150150
Buffer.add_string b (Bigstringaf.substring bs ~off ~len);
151151
read body ~on_eof ~on_read in

src/server/websocket/cohttp/wsCommon.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ let ws_react react pong rclose rsend notify_close fr =
3030
else !rsend @@ Some (close 1000);
3131
Option.iter Lwt.async (snd !rclose);
3232
rclose := true, None;
33-
Lwt.wakeup notify_close ()
33+
Lwt.wakeup_later notify_close ()
3434
| Opcode.Pong -> pong fr.content
3535
| Opcode.Text | Opcode.Binary -> ws_react_content react !rsend fr.content
3636
| _ -> !rsend @@ Some (close 1002)

src/server/websocket/httpun/wsHttpun.real.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ let ws_react_content react notify_close wsd content =
2828
| Error (`handler_error content) -> send ~kind:`Text ~content wsd
2929
| Error _ ->
3030
close ~code:`Internal_server_error wsd;
31-
Lwt.wakeup notify_close ()
31+
Lwt.wakeup_later notify_close ()
3232

3333
let read_payload ~payload f =
3434
let b = Buffer.create 100 in
@@ -48,14 +48,14 @@ let ws_react react pong notify_close ~opcode ~payload wsd = match opcode with
4848
read_payload ~payload @@ fun content ->
4949
let application_data = make_data content in
5050
Wsd.send_pong ~application_data wsd
51-
| `Connection_close -> Wsd.close wsd; Lwt.wakeup notify_close ()
51+
| `Connection_close -> Wsd.close wsd; Lwt.wakeup_later notify_close ()
5252
| `Pong -> read_payload ~payload pong
5353
| `Text | `Binary -> read_payload ~payload (ws_react_content react notify_close wsd)
5454
| _ -> close ~code:`Protocol_error wsd
5555

5656
let ws_loop bg notify_close wsd =
5757
let send : (EzAPIServerUtils.Directory.ws_frame, EzAPIServerUtils.Directory.handler_error) result -> unit = function
58-
| Error _ -> close wsd; Lwt.wakeup notify_close ()
58+
| Error _ -> close wsd; Lwt.wakeup_later notify_close ()
5959
| Ok `none -> ()
6060
| Ok (`binary content) -> send ~kind:`Binary ~content wsd
6161
| Ok (`text content) -> send ~kind:`Text ~content wsd in

src/websocket/js/ezWs.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ let connect ?msg ?protocols ?error ~react url =
6060
| None -> (); Js._true);
6161
let conn, n = Lwt.wait () in
6262
socket##.onclose := Dom.handler @@ (fun _e ->
63-
Lwt.wakeup n @@ Ok (); Js._true);
63+
Lwt.wakeup_later n @@ Ok (); Js._true);
6464
socket##.onopen := Dom.handler @@ (fun _e ->
65-
Lwt.wakeup n0 (Ok {action; conn}); Js._true);
65+
Lwt.wakeup_later n0 (Ok {action; conn}); Js._true);
6666
w0)
6767
(fun exn -> Lwt.return_error (Printexc.to_string exn))
6868

src/websocket/unix/httpun/ezWs.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ let error_handler notifier e =
2828
| `Malformed_response err -> Format.sprintf "malformed response: %s" err
2929
| `Invalid_response_body_length _ -> "invalid body length"
3030
| `Exn exn -> Printexc.to_string exn in
31-
Lwt.wakeup notifier (Error e)
31+
Lwt.wakeup_later notifier (Error e)
3232

3333
let send ~content wsd =
3434
let len, off = String.length content, 0 in
@@ -55,7 +55,7 @@ let websocket_handler ?error ~react notifier action_notifier wsd =
5555
Wsd.close ?code wsd; Lwt.return_ok () in
5656
let send content = send ~content wsd; Lwt.return_ok () in
5757
let action = { send; close } in
58-
Lwt.wakeup action_notifier action;
58+
Lwt.wakeup_later action_notifier action;
5959
let frame ~opcode ~is_fin ~len:_ payload = match opcode with
6060
| `Ping ->
6161
read_payload ~payload @@ fun content ->
@@ -74,10 +74,10 @@ let websocket_handler ?error ~react notifier action_notifier wsd =
7474
Lwt.return_unit)
7575
| `Connection_close ->
7676
Wsd.close wsd;
77-
Lwt.wakeup notifier (Ok ())
77+
Lwt.wakeup_later notifier (Ok ())
7878
| _ ->
7979
Wsd.close ~code:`Protocol_error wsd;
80-
Lwt.wakeup notifier (Error "protocol error") in
80+
Lwt.wakeup_later notifier (Error "protocol error") in
8181
let eof ?error () =
8282
Option.iter (function `Exn exn -> Format.eprintf "websocket eof error: %s@." (Printexc.to_string exn)) error;
8383
Wsd.close wsd in

0 commit comments

Comments
 (0)