[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [RFC PATCH 8/8] tools/console: remove 5s bodge in console client
The bug described in the comment has been fixed in libxl. Since console client is a private binary and libxl is the only supported toolstack in upstream, remove the bodge to simplify code. Note that the xs watch is still needed because the console client relies on it to tell if the tty is gone. Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx> --- tools/console/client/main.c | 48 +++++++++++++++++++-------------------------- 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/tools/console/client/main.c b/tools/console/client/main.c index 2751eb7..275b49a 100644 --- a/tools/console/client/main.c +++ b/tools/console/client/main.c @@ -96,38 +96,34 @@ void cfmakeraw(struct termios *termios_p) } #endif -static int get_pty_fd(struct xs_handle *xs, char *path, int seconds) +static int get_pty_fd(struct xs_handle *xs, char *path) /* Check for a pty in xenstore, open it and return its fd. * Assumes there is already a watch set in the store for this path. */ { struct timeval tv; fd_set watch_fdset; int xs_fd = xs_fileno(xs), pty_fd = -1; - int start, now; unsigned int len = 0; char *pty_path, **watch_paths; - start = now = time(NULL); - do { - tv.tv_usec = 0; - tv.tv_sec = (start + seconds) - now; - FD_ZERO(&watch_fdset); - FD_SET(xs_fd, &watch_fdset); - if (select(xs_fd + 1, &watch_fdset, NULL, NULL, &tv)) { - /* Read the watch to drain the buffer */ - watch_paths = xs_read_watch(xs, &len); - free(watch_paths); - /* We only watch for one thing, so no need to - * disambiguate: just read the pty path */ - pty_path = xs_read(xs, XBT_NULL, path, &len); - if (pty_path != NULL && pty_path[0] != '\0') { - pty_fd = open(pty_path, O_RDWR | O_NOCTTY); - if (pty_fd == -1) - warn("Could not open tty `%s'", pty_path); - } - free(pty_path); + tv.tv_usec = 0; + tv.tv_sec = 0; + FD_ZERO(&watch_fdset); + FD_SET(xs_fd, &watch_fdset); + if (select(xs_fd + 1, &watch_fdset, NULL, NULL, &tv)) { + /* Read the watch to drain the buffer */ + watch_paths = xs_read_watch(xs, &len); + free(watch_paths); + /* We only watch for one thing, so no need to + * disambiguate: just read the pty path */ + pty_path = xs_read(xs, XBT_NULL, path, &len); + if (pty_path != NULL && pty_path[0] != '\0') { + pty_fd = open(pty_path, O_RDWR | O_NOCTTY); + if (pty_fd == -1) + warn("Could not open tty `%s'", pty_path); } - } while (pty_fd == -1 && (now = time(NULL)) < start + seconds); + free(pty_path); + } #ifdef __sun__ if (pty_fd != -1) { @@ -201,7 +197,7 @@ static int console_loop(int fd, struct xs_handle *xs, char *pty_path, } if (FD_ISSET(xs_fileno(xs), &fds)) { - int newfd = get_pty_fd(xs, pty_path, 0); + int newfd = get_pty_fd(xs, pty_path); if (fd != -1) close(fd); if (newfd == -1) @@ -454,11 +450,7 @@ int main(int argc, char **argv) err(errno, "Can't set watch for console pty"); xsfd = xs_fileno(xs); - /* 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. */ - spty = get_pty_fd(xs, path, 5); + spty = get_pty_fd(xs, path); if (spty == -1) { err(errno, "Could not read tty from store"); } -- 2.1.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |