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-changelog

[Xen-changelog] [xen-unstable] xenstored: Delay forking until after list

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] xenstored: Delay forking until after listening sockets are
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 27 Mar 2008 05:30:17 -0700
Delivery-date: Thu, 27 Mar 2008 05:30:25 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1206537702 0
# Node ID 21d9575c669ee6e88fb77052e775f74bfbeaf7e6
# Parent  f471ea3665469a0610cec53c1931c1d85d54efb7
xenstored: Delay forking until after listening sockets are
opened. Also, in startup xend script, delay further startup until
xenstored initial child process has exited. This serialises xenstored
startup with that of other daemons (e.g., xenconsoled).

Signed-off-by: Bastian Blank <waldi@xxxxxxxxxx>
---
 tools/misc/xend                 |   16 +++++++++++-----
 tools/xenstore/xenstored_core.c |   25 +++++++++++++------------
 2 files changed, 24 insertions(+), 17 deletions(-)

diff -r f471ea366546 -r 21d9575c669e tools/misc/xend
--- a/tools/misc/xend   Wed Mar 26 13:15:33 2008 +0000
+++ b/tools/misc/xend   Wed Mar 26 13:21:42 2008 +0000
@@ -95,11 +95,17 @@ def start_xenstored():
         f.close()
     except:
         pass
-    XENSTORED_TRACE = os.getenv("XENSTORED_TRACE")
-    cmd = "xenstored --pid-file /var/run/xenstore.pid"
-    if XENSTORED_TRACE:
-        cmd += " -T /var/log/xen/xenstored-trace.log"
-    s,o = commands.getstatusoutput(cmd)
+    args = ['xenstored', "--pid-file", pidfname]
+    if os.getenv("XENSTORED_TRACE"):
+        args.extend(["-T", "/var/log/xen/xenstored-trace.log"])
+    pid = os.fork()
+    if pid == 0:
+        os.execvp('xenstored', args)
+    p, status = os.waitpid(pid, 0)
+    if os.WIFEXITED(status):
+        status = os.WEXITSTATUS(status)
+        if status:
+            raise RuntimeError("Failed to start xenstored: %d" % status)
 
 def start_consoled():
     if os.fork() == 0:
diff -r f471ea366546 -r 21d9575c669e tools/xenstore/xenstored_core.c
--- a/tools/xenstore/xenstored_core.c   Wed Mar 26 13:15:33 2008 +0000
+++ b/tools/xenstore/xenstored_core.c   Wed Mar 26 13:21:42 2008 +0000
@@ -1839,13 +1839,6 @@ int main(int argc, char *argv[])
                }
        }
 
-       if (dofork) {
-               openlog("xenstored", 0, LOG_DAEMON);
-               daemonize();
-       }
-       if (pidfile)
-               write_pidfile(pidfile);
-
        /* Talloc leak reports go to stderr, which is closed if we fork. */
        if (!dofork)
                talloc_enable_leak_report_full();
@@ -1899,22 +1892,30 @@ int main(int argc, char *argv[])
        /* Restore existing connections. */
        restore_existing_connections();
 
-       if (outputpid) {
-               printf("%ld\n", (long)getpid());
-               fflush(stdout);
-       }
-
        /* redirect to /dev/null now we're ready to accept connections */
        if (dofork) {
                int devnull = open("/dev/null", O_RDWR);
                if (devnull == -1)
                        barf_perror("Could not open /dev/null\n");
+
+               openlog("xenstored", 0, LOG_DAEMON);
+
+               daemonize();
+
+               if (outputpid) {
+                       printf("%ld\n", (long)getpid());
+                       fflush(stdout);
+               }
+
                dup2(devnull, STDIN_FILENO);
                dup2(devnull, STDOUT_FILENO);
                dup2(devnull, STDERR_FILENO);
                close(devnull);
                xprintf = trace;
        }
+
+       if (pidfile)
+               write_pidfile(pidfile);
 
        signal(SIGHUP, trigger_reopen_log);
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] xenstored: Delay forking until after listening sockets are, Xen patchbot-unstable <=