]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/xen.git/commitdiff
oxenstored: fix systemd socket activation
authorWei Liu <wei.liu2@citrix.com>
Mon, 10 Aug 2015 08:00:18 +0000 (09:00 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Thu, 13 Aug 2015 09:24:02 +0000 (10:24 +0100)
Use the correct API sd_listen_fds to determine whether the process is
started by systemd.

Change sd_booted to launched_by_systemd to avoid confusion with
systemd's API.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Dave Scott <dave.scott@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Tested-by: Andrew Cooper <andrew.cooper3@citrix.com>
tools/ocaml/xenstored/systemd.ml
tools/ocaml/xenstored/systemd.mli
tools/ocaml/xenstored/systemd_stubs.c
tools/ocaml/xenstored/utils.ml
tools/ocaml/xenstored/xenstored.ml

index 2aa39eaf7120bd0f9046b80133e07640de6e5122..732446d8e57fc995c2edce485fd20340c6628667 100644 (file)
@@ -13,5 +13,5 @@
  *)
 
 external sd_listen_fds: string -> Unix.file_descr = "ocaml_sd_listen_fds"
-external sd_booted: unit -> bool = "ocaml_sd_booted"
+external launched_by_systemd: unit -> bool = "ocaml_launched_by_systemd"
 external sd_notify_ready: unit -> unit = "ocaml_sd_notify_ready"
index 85c9f2eb85a179448a36a22f80d2a14799440e13..538fc5e1b523e6a6b24787129f06b8cd20397226 100644 (file)
@@ -17,8 +17,8 @@
  *  us do sanity checks on the expected sockets *)
 val sd_listen_fds: string -> Unix.file_descr
 
-(** Tells us whether or not systemd support was compiled in *)
-val sd_booted: unit -> bool
+(** Tells us whether the process is launched by systemd *)
+val launched_by_systemd: unit -> bool
 
 (** Tells systemd we're ready *)
 external sd_notify_ready: unit -> unit = "ocaml_sd_notify_ready"
index d924ff1bd793ff3365924dd71add10e092ee3131..1bd5deaf53d17bad820ba1bd27d0ddc788081051 100644 (file)
@@ -92,14 +92,14 @@ CAMLprim value ocaml_sd_listen_fds(value connect_to)
        CAMLreturn(sock_ret);
 }
 
-CAMLprim value ocaml_sd_booted(value ignore)
+CAMLprim value ocaml_launched_by_systemd(value ignore)
 {
        CAMLparam1(ignore);
        CAMLlocal1(ret);
 
        ret = Val_false;
 
-       if (sd_booted())
+       if (sd_listen_fds(0) > 0)
                ret = Val_true;
 
        CAMLreturn(ret);
@@ -129,7 +129,7 @@ CAMLprim value ocaml_sd_listen_fds(value connect_to)
        CAMLreturn(sock_ret);
 }
 
-CAMLprim value ocaml_sd_booted(value ignore)
+CAMLprim value ocaml_launched_by_systemd(value ignore)
 {
        CAMLparam1(ignore);
        CAMLlocal1(ret);
index 61321c619b64148ba25525ec83492bbe14a4fbcd..9f82c1ca8da699246f88f3ea02d479d0484999be 100644 (file)
@@ -84,7 +84,7 @@ let create_regular_unix_socket name =
         sock
 
 let create_unix_socket name =
-        if Systemd.sd_booted() then
+        if Systemd.launched_by_systemd() then
                 Systemd.sd_listen_fds name
         else
                 create_regular_unix_socket name
index bfe689b0f8ddc135e97e133ff573cbe73a938931..f4840247b67cffc924e2efb6a395de7ee56bf657 100644 (file)
@@ -431,7 +431,7 @@ let _ =
        while not !quit
        do
                try
-                        if Systemd.sd_booted() then
+                        if Systemd.launched_by_systemd() then
                                 Systemd.sd_notify_ready ();
                        main_loop ()
                with exc ->