WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-api

[Xen-API] [PATCH] Fix a bug in the previous -debug-on-fail patch

To: xen-api@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-API] [PATCH] Fix a bug in the previous -debug-on-fail patch
From: Zheng Li <dev@xxxxxxxx>
Date: Sat, 10 Apr 2010 09:25:59 -0000
Delivery-date: Sat, 10 Apr 2010 02:01:53 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-api-request@lists.xensource.com?subject=help>
List-id: Discussion of API issues surrounding Xen <xen-api.lists.xensource.com>
List-post: <mailto:xen-api@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-api-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mercurial-patchbomb/1.3.1
I didn't realize that xe would initial an auxilary stunnel link in certain 
opearions, so that some of the global variables we stored for the main link 
might be overwritten unexpectedly. Now the protection is added. What a typical 
example about how global mutable variable is bad, but I won't really regret 
having chosen such a solution because it demanded the least code modification, 
and hence safer for such complex software in that sense.


Signed-off-by: Zheng Li <dev@xxxxxxxx>


 ocaml/xe-cli/newcli.ml |  16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)


diff -r 78bbf8bf7770 -r 30ea2ac51050 ocaml/xe-cli/newcli.ml
--- a/ocaml/xe-cli/newcli.ml    Wed Mar 31 10:30:27 2010 +0100
+++ b/ocaml/xe-cli/newcli.ml    Sat Apr 10 10:15:21 2010 +0100
@@ -209,7 +209,7 @@
   let x = Stunnel.connect ~use_external_fd_wrapper:false 
     ~write_to_log:(fun x -> debug "stunnel: %s\n%!" x) 
     ~extended_diagnosis:(!debug_file <> None) server port in
-  stunnel_process := Some x;
+  if !stunnel_process = None then stunnel_process := Some x;
   Unix.in_channel_of_descr x.Stunnel.fd, Unix.out_channel_of_descr x.Stunnel.fd
 
 let open_tcp server =
@@ -261,7 +261,10 @@
 
   let exit_code = ref None in
   while !exit_code = None do
-    while (match Unix.select [ofd] [] [] 5.0 with
+    (* Wait for input asynchronously so that we can check the status
+       of Stunnel every now and then, for better debug/dignosis.
+    *)
+    while (match Unix.select [ifd] [] [] 5.0 with
            | _ :: _, _, _ -> false
            | _ -> 
                match !stunnel_process with
@@ -443,7 +446,7 @@
            exit 0
     end;
 
-    if List.length args < 2 then usage () else
+    if List.length args < 2 then (usage (); exit 0) else
       begin
              let extra_args = try Sys.getenv "XE_EXTRA_ARGS" with _ -> "" in
              let split_extra = List.filter (fun s -> String.length s > 1) 
(String.split ',' extra_args) in    
@@ -488,7 +491,7 @@
   | Unexpected_msg m ->
       error "Unexpected message from server: %s" (string_of_message m)
   | Stunnel_exit (i, e) ->
-      error "Stunnel process %d %s" i 
+      error "Stunnel process %d %s.\n" i 
         (match e with 
          | Unix.WEXITED c -> "existed with exit code " ^ string_of_int c
          | Unix.WSIGNALED c -> "killed by signal " ^ string_of_int c
@@ -496,7 +499,7 @@
   | e ->
            error "Unhandled exception\n%s\n" (Printexc.to_string e) in
   begin match !stunnel_process with
-  | Some p ->
+  | Some p -> 
       if Sys.file_exists p.Stunnel.logfile then 
         begin
           if !exit_status <> 0 then
@@ -505,7 +508,8 @@
              with e -> debug "%s\n" (Printexc.to_string e));
           try Unix.unlink p.Stunnel.logfile with _ -> ()
         end;
-      Stunnel.disconnect p
+      (try Stunnel.disconnect p 
+       with Unix.Unix_error(Unix.ECHILD, _, _) -> ())
   | None -> ()
   end;
   begin match !debug_file, !debug_channel with

Attachment: xen-api.patch
Description: Text Data

_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-API] [PATCH] Fix a bug in the previous -debug-on-fail patch, Zheng Li <=