]> xenbits.xensource.com Git - xcp/xen-api-libs.git/commitdiff
CA-33440: when starting an stunnel process, careful to handle the case where we still...
authorDavid Scott <dave.scott@eu.citrix.com>
Fri, 18 Dec 2009 20:48:37 +0000 (20:48 +0000)
committerDavid Scott <dave.scott@eu.citrix.com>
Fri, 18 Dec 2009 20:48:37 +0000 (20:48 +0000)
Signed-off-by: David Scott <dave.scott@eu.citrix.com>
stunnel/stunnel.ml

index 0df7c60444244f3ad01868d30e075b0eec2a6820..1d3ee9bc06657b7a83e657097b77155d10ab409e 100644 (file)
@@ -150,19 +150,20 @@ let attempt_one_connect ?unique_id ?(use_external_fd_wrapper = true) ?(write_to_
           Forkhelpers.Dup2(data_in, Unix.stdout);
           Forkhelpers.Dup2(logfd, Unix.stderr) ] in
        let fds_needed = [ Unix.stdin; Unix.stdout; Unix.stderr; config_out ] in
-       let args = [ "-fd"; config_out_uuid ] in
+       let args_external = [ "-fd"; config_out_uuid ] in
+          let args_internal = [ "-fd"; string_of_int (Unixext.int_of_file_descr config_out) ] in
        if use_external_fd_wrapper then begin
-        let cmdline = Printf.sprintf "Using commandline: %s\n" (String.concat " " (path::args)) in
+        let cmdline = Printf.sprintf "Using commandline: %s\n" (String.concat " " (path::args_external)) in
         write_to_log cmdline;
        end;
        t.pid <-
         if use_external_fd_wrapper
-        then Forkhelpers.safe_close_and_exec (Some data_in) (Some data_in) (Some logfd) [(config_out_uuid, config_out)] path args
+        then Forkhelpers.safe_close_and_exec (Some data_in) (Some data_in) (Some logfd) [(config_out_uuid, config_out)] path args_external
         else Forkhelpers.fork_and_exec ~pre_exec:
                          (fun _ -> 
                            List.iter Forkhelpers.do_fd_operation fdops;
                            Unixext.close_all_fds_except fds_needed) 
-                         (path::args);
+                         (path::args_internal);
        List.iter close [ data_in; config_out; ]; 
        (* Make sure we close config_in eventually *)
        finally