[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-API] [PATCH] CA-46210: use nice to work around forkhelpers waitpid race



 stdext/gzip.ml |  25 ++++++++++++-------------
 1 files changed, 12 insertions(+), 13 deletions(-)


# HG changeset patch
# User Marcus Granado <marcus.granado@xxxxxxxxxx>
# Date 1285861669 -3600
# Node ID 74ad0713ac392aace8acbabc4b4a9e05a0279896
# Parent  7245d00318f6fb778486bc5f99d8c6ac0cb896a1
CA-46210: use nice to work around forkhelpers waitpid race

Signed-off-by: Marcus Granado <marcus.granado@xxxxxxxxxxxxx>

diff -r 7245d00318f6 -r 74ad0713ac39 stdext/gzip.ml
--- a/stdext/gzip.ml
+++ b/stdext/gzip.ml
@@ -28,19 +28,18 @@
   | Active  (** we provide a function which writes into the compressor and a 
fd output *)
   | Passive (** we provide an fd input and a function which reads from the 
compressor *)
 
-(* renice/ionice the pid with lowest priority so that it doesn't *)
-(* use up all cpu resources in dom0 *)
-let lower_priority pid =
-  let pid=Printf.sprintf "%d" (Forkhelpers.getpid pid) in
-  (* renice 19 -p pid *)
-  let renice="/usr/bin/renice" in
-  let renice_args = ["19";"-p";pid] in
-  let _=Forkhelpers.execute_command_get_output renice renice_args in
-  (* ionice -c 3 [idle] -p pid *)
+(* start cmd with lowest priority so that it doesn't 
+   use up all cpu resources in dom0 
+*)
+let lower_priority cmd args =
   let ionice="/usr/bin/ionice" in
-  let ionice_args = ["-c";"3";"-p";pid] in
-  let _=Forkhelpers.execute_command_get_output ionice ionice_args in
-  ()
+  let ionice_args=["-c";"3"] in (*io idle*)
+  let nice="/bin/nice" in
+  let nice_args=["-n";"19"] in (*lowest priority*)
+  let extra_args=nice_args@[ionice]@ionice_args in
+  let new_cmd=nice in
+  let new_args=extra_args@[cmd]@args in
+  (new_cmd,new_args)
 
 (** Runs a zcat process which is either:
     i) a compressor; or (ii) a decompressor
@@ -69,11 +68,11 @@
               Some zcat_in,                               (* output goes into 
the pipe+fn *) 
               zcat_in,                                    (* we close this now 
*)
               zcat_out in                                 (* close this before 
waitpid *)
+        let (gzip,args)=lower_priority gzip args in
         let pid = Forkhelpers.safe_close_and_exec stdin stdout None [] gzip 
args in
         close close_now;
    finally
      (fun () -> 
-       (try lower_priority pid with _->()); (* lowest priority to gzip *)
        f close_later
      )
           (fun () ->

Attachment: xen-api-libs.hg.patch
Description: Text Data

_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.