Skip to content

Commit

Permalink
CAR-1744: function that supports getting xenopsd task result while sy…
Browse files Browse the repository at this point in the history
…ncing

The current sync_task implementation always ignores xenopsd task result. Here
we add a new function which will get the result while syncing is done.

Signed-off-by: Zheng Li <dev@zheng.li>
  • Loading branch information
zli committed Sep 9, 2015
1 parent ed6840d commit 0447fec
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions ocaml/xapi/xapi_xenops.ml
Expand Up @@ -2055,8 +2055,8 @@ let success_task queue_name f dbg id =
(fun () ->
let t = Client.TASK.stat dbg id in
match t.Task.state with
| Task.Completed _ -> f t
| Task.Failed x ->
| Task.Completed r -> f t;r.Task.result
| Task.Failed x ->
let exn = exn_of_exnty (Exception.exnty_of_rpc x) in
let bt = Backtrace.t_of_sexp (Sexplib.Sexp.of_string t.Task.backtrace) in
Backtrace.add exn bt;
Expand Down Expand Up @@ -2183,13 +2183,15 @@ let update_debug_info __context t =
debug "Failed to add %s = %s to task %s: %s" k v (Ref.string_of task) (Printexc.to_string e)
) debug_info

let sync_with_task __context queue_name x =
let sync_with_task_result __context queue_name x =
let dbg = Context.string_of_task __context in
x |> register_task __context queue_name |> wait_for_task queue_name dbg |> unregister_task __context queue_name |> success_task queue_name (update_debug_info __context) dbg

let sync_with_task __context queue_name x = sync_with_task_result __context queue_name x |> ignore

let sync __context queue_name x =
let dbg = Context.string_of_task __context in
x |> wait_for_task queue_name dbg |> success_task queue_name (update_debug_info __context) dbg
x |> wait_for_task queue_name dbg |> success_task queue_name (update_debug_info __context) dbg |> ignore

let pause ~__context ~self =
let queue_name = queue_of_vm ~__context ~self in
Expand Down

0 comments on commit 0447fec

Please sign in to comment.