From: Vincent Hanquez Date: Wed, 26 Aug 2009 09:41:31 +0000 (+0100) Subject: add an exception handler in the threaded case. X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=29b0921c9f9d1455f80d6b48baee5ec4ecf060cf;p=xenclient%2Ftoolstack.git add an exception handler in the threaded case. make sure an exception in the threaded case received will return an error to the caller. --- diff --git a/xenvm/xenvm.ml b/xenvm/xenvm.ml index 989193c..aee53b7 100644 --- a/xenvm/xenvm.ml +++ b/xenvm/xenvm.ml @@ -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 =