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] Wait a little bit for tty to appear.

# HG changeset patch
# User cl349@xxxxxxxxxxxxxxxxxxxx
# Node ID 6d4c0bfc3c1c15d1871d17698bfd78a9ea05aff5
# Parent  f41f8d753b7a94a06ec77727ca1c0db557b49e1e
Wait a little bit for tty to appear.
There is a race condition that occurs after xend creates a domain.
The console client might be running before the console daemon has
noticed the new domain and setup a pty for it.
Signed-off-by: Anthony Liguori <aliguori@xxxxxxxxxx>
Signed-off-by: Christian Limpach <Christian.Limpach@xxxxxxxxxxxx>

diff -r f41f8d753b7a -r 6d4c0bfc3c1c tools/console/client/main.c
--- a/tools/console/client/main.c       Wed Aug 31 09:32:52 2005
+++ b/tools/console/client/main.c       Wed Aug 31 10:24:43 2005
@@ -176,6 +176,7 @@
        unsigned int len = 0;
        struct xs_handle *xs;
        char *end;
+       time_t now;
 
        while((ch = getopt_long(argc, argv, sopt, lopt, &opt_ind)) != -1) {
                switch(ch) {
@@ -215,13 +216,37 @@
 
        snprintf(path, sizeof(path), "/console/%d/tty", domid);
        str_pty = xs_read(xs, path, &len);
+
        /* FIXME consoled currently does not assume domain-0 doesn't have a
           console which is good when we break domain-0 up.  To keep us
           user friendly, we'll bail out here since no data will ever show
           up on domain-0. */
-       if (domid == 0 || str_pty == NULL) {
+       if (domid == 0) {
                err(errno, "Could not read tty from store");
        }
+
+       /* Wait a little bit for tty to appear.  There is a race
+          condition that occurs after xend creates a domain.  This
+          code might be running before consoled has noticed the new
+          domain and setup a pty for it.
+
+          A xenstore watch would slightly improve responsiveness but
+          a timeout would still be needed since we don't want to
+          block forever if given an invalid domain or worse yet, a
+          domain that someone else has connected to. */
+
+       now = time(0);
+       while (str_pty == NULL && (now + 5) > time(0)) {
+               struct timeval tv = { 0, 500 };
+               select(0, NULL, NULL, NULL, &tv); /* pause briefly */
+
+               str_pty = xs_read(xs, path, &len);
+       }
+
+       if (str_pty == NULL) {
+               err(errno, "Could not read tty from store");
+       }
+
        spty = open(str_pty, O_RDWR | O_NOCTTY);
        if (spty == -1) {
                err(errno, "Could not open tty `%s'", str_pty);

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] Wait a little bit for tty to appear., Xen patchbot -unstable <=