Oxenstored only needs to notify systemd its readiness state once. Move
sd_notify_ready out of main loop.

Signed-off-by: Wei Liu <wei.l...@citrix.com>
---
Cc: Dave Scott <dave.sc...@eu.citrix.com>

For 4.6: avoid wasting CPU cycles, easy to reason its correctness.

There is a small risk that either I wrote the wrong code or I
misunderstand the usage of systemd API. However I've tested the modified
oxenstored it worked fine.
---
 tools/ocaml/xenstored/xenstored.ml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/ocaml/xenstored/xenstored.ml 
b/tools/ocaml/xenstored/xenstored.ml
index 409223d..5e32501 100644
--- a/tools/ocaml/xenstored/xenstored.ml
+++ b/tools/ocaml/xenstored/xenstored.ml
@@ -428,11 +428,11 @@ let _ =
                process_domains store cons domains
                in
 
+       if Systemd.booted_by_systemd () then
+               Systemd.sd_notify_ready ();
        while not !quit
        do
                try
-                        if Systemd.booted_by_systemd() then
-                                Systemd.sd_notify_ready ();
                        main_loop ()
                with exc ->
                        error "caught exception %s" (Printexc.to_string exc);
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

Reply via email to