From 798fa9138c7af648323ee1a16bfbd92cf59c4b8e Mon Sep 17 00:00:00 2001 From: Kaifeng Zhu Date: Tue, 2 Jun 2015 13:28:42 +0800 Subject: [PATCH] CA-172250: Local allocator handles requests in parallel Signed-off-by: Kaifeng Zhu --- xenvm-local-allocator/local_allocator.ml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/xenvm-local-allocator/local_allocator.ml b/xenvm-local-allocator/local_allocator.ml index 4f6cfe0..ae88ad4 100644 --- a/xenvm-local-allocator/local_allocator.ml +++ b/xenvm-local-allocator/local_allocator.ml @@ -473,10 +473,7 @@ let main use_mock config daemon socket journal fromLVM toLVM = debug "Binding and listening on the socket"; Lwt_unix.bind s (Lwt_unix.ADDR_UNIX(config.Config.socket)); Lwt_unix.listen s 5; - let rec unix () = - debug "Calling accept on the socket"; - Lwt_unix.accept s - >>= fun (fd, _) -> + let conn_handler fd () = let ic = Lwt_io.of_fd ~mode:Lwt_io.input fd in let oc = Lwt_io.of_fd ~mode:Lwt_io.output ~close:return fd in (* read one line *) @@ -490,7 +487,12 @@ let main use_mock config daemon socket journal fromLVM toLVM = Lwt_io.flush oc >>= fun () -> Lwt_io.close ic - >>= fun () -> + in + let rec unix () = + debug "Calling accept on the socket"; + Lwt_unix.accept s + >>= fun (fd, _) -> + async (conn_handler fd); unix () in let listen_unix = unix () in debug "Waiting forever for requests";