]> xenbits.xen.org Git - xenclient/toolstack.git/commitdiff
add an exception handler in the threaded case.
authorVincent Hanquez <vincent.hanquez@eu.citrix.com>
Wed, 26 Aug 2009 09:41:31 +0000 (10:41 +0100)
committerVincent Hanquez <vincent.hanquez@eu.citrix.com>
Wed, 26 Aug 2009 09:41:31 +0000 (10:41 +0100)
make sure an exception in the threaded case received will return an error to the caller.

xenvm/xenvm.ml

index 989193cf580773ff7e32382a6f7a728aa8d7957c..aee53b7d4a68b04b473572824b80b062f07471a2 100644 (file)
@@ -667,6 +667,12 @@ let monitor_rpc_dbus state =
                        | Xenvmlib.Error err -> DBus.Message.new_error msg DBus.ERR_FAILED err
                        | _                  -> DBus.Message.new_error msg DBus.ERR_FAILED "?"
                        in
+               let do_task_exn state x =
+                       try xenvmlib_to_dbus (do_task state x)
+                       with exn ->
+                               let s = sprintf "exception: %s" (Printexc.to_string exn) in
+                               DBus.Message.new_error msg DBus.ERR_FAILED s
+                       in
                (* if the tasks need to be threaded like start,reboot,.. we returns
                  none to the caller and create a thread that is going to populate a queue
                  with the return message when ready *)
@@ -678,13 +684,12 @@ let monitor_rpc_dbus state =
                        if task_descr.Tasks.need_threading then (
                                info "creating thread for handling %s" msg_method;
                                thread_create (fun () ->
-                                       let rep = do_task state (act, taskargs) in
-                                       let rep = xenvmlib_to_dbus rep in
+                                       let rep = do_task_exn state (act, taskargs) in
                                        Mutex.execute outgoing_mutex (fun () -> Queue.push rep outgoing);
                                ) ();
                                None
                        ) else
-                               Some (xenvmlib_to_dbus (do_task state (act, taskargs)))
+                               Some (do_task_exn state (act, taskargs))
                in
 
        let process_method_call msg =