Skip to content

Commit 657d6b2

Browse files
committed
Avoid calling Lwt_main.run twice
This makes the code hard to reason about.
1 parent e7bfc58 commit 657d6b2

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/server/ocsigen_server.ml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ let main config =
220220
in
221221
let extensions_connector = Ocsigen_extensions.compute_result in
222222
let run () =
223-
Lwt_main.run (Ocsigen_messages.open_files ());
223+
Ocsigen_messages.open_files () >>= fun () ->
224224
let ports = Ocsigen_config.get_ports ()
225225
and ssl_ports = Ocsigen_config.get_ssl_ports () in
226226
let connection = match ports with [] -> [`All, 80] | l -> l in
@@ -336,8 +336,7 @@ let main config =
336336
>>= f
337337
in
338338
ignore (f () : 'a Lwt.t));
339-
Lwt_main.run
340-
@@ Lwt.join
339+
Lwt.join
341340
(List.map
342341
(fun (address, port) ->
343342
Ocsigen_cohttp.service ~address ~port
@@ -387,14 +386,14 @@ let main config =
387386
then
388387
let pid = Unix.fork () in
389388
if pid = 0
390-
then run ()
389+
then Lwt_main.run (run ())
391390
else (
392391
Ocsigen_messages.console (fun () ->
393392
"Process " ^ string_of_int pid ^ " detached");
394393
write_pid pid)
395394
else (
396395
write_pid (Unix.getpid ());
397-
run ())
396+
Lwt_main.run (run ()))
398397
with e ->
399398
let msg, errno = errmsg e in
400399
Ocsigen_messages.errlog msg;

0 commit comments

Comments
 (0)