Skip to content

Commit 1a3cc44

Browse files
author
Jon Ludlam
authored
Merge pull request xapi-project#32 from DeliZhangX/private/deliz/CA-248467-PR
CA-248467: message-cli tail --follow causes VM reboot too slow
2 parents 007b15c + a78261e commit 1a3cc44

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed

switch/switch_main.ml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,6 @@ let make_server config =
212212
Lwt_condition.broadcast queues_c ();
213213
return () in
214214

215-
(* Held while processing a non-blocking request *)
216-
let m = Lwt_mutex.create () in
217-
218215
(* (Response.t * Body.t) Lwt.t *)
219216
let callback (_, conn_id) req body =
220217
(* Make sure we replay the log before processing requests *)
@@ -254,7 +251,7 @@ let make_server config =
254251
| _, _ -> return () )
255252
>>= fun () ->
256253

257-
Lwt_mutex.with_lock m
254+
Lwt_mutex.with_lock Switch_main_helper.m
258255
(fun () ->
259256
process_request conn_id_s !queues session request
260257
>>= fun (op_opt, response) ->
@@ -280,7 +277,7 @@ let make_server config =
280277
info "Session %s cleaning up" session;
281278
let qs = Q.owned_queues !queues session in
282279
let ops = Q.StringSet.fold (fun x ops -> Q.Directory.remove !queues x :: ops) qs [] in
283-
Lwt_mutex.with_lock m
280+
Lwt_mutex.with_lock Switch_main_helper.m
284281
(fun () ->
285282
perform ops
286283
) in

switch/switch_main_helper.ml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
(*
2+
* Copyright (c) Citrix Systems Inc.
3+
*
4+
* Permission to use, copy, modify, and distribute this software for any
5+
* purpose with or without fee is hereby granted, provided that the above
6+
* copyright notice and this permission notice appear in all copies.
7+
*
8+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14+
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15+
*)
16+
open Lwt
17+
18+
(* Held while processing a non-blocking request *)
19+
let m = Lwt_mutex.create ()
20+

switch/trace.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ let get from timeout : (int64 * Protocol.Event.t) list Lwt.t =
4242
let sleep = Lwt_unix.sleep timeout in
4343
let rec wait_for_data () =
4444
if !next_id <= from then
45-
Lwt_condition.wait c >>= wait_for_data
45+
Lwt_condition.wait ?mutex:(Some Switch_main_helper.m) c >>= wait_for_data
4646
else return ()
4747
in
4848
(* Wait until some data is available ie. when next_id > from (or timeout) *)

0 commit comments

Comments
 (0)