]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
"busy" field set to -1 instead of 0 3214/head
authorRachid Koucha <47061324+Rachid-Koucha@users.noreply.github.com>
Fri, 6 Dec 2019 14:07:47 +0000 (15:07 +0100)
committerGitHub <noreply@github.com>
Fri, 6 Dec 2019 14:07:47 +0000 (15:07 +0100)
"busy" field is assigned with the command socket descriptor when the terminal is in use. So, use "-1" to disable it.

Signed-off-by: Rachid Koucha <rachid.koucha@gmail.com>
src/lxc/terminal.c

index aba8bb9217b9e114082a26c7e57af3acd5923c60..26b2d50d7c5128f806fe48875e3028dd26b27b25 100644 (file)
@@ -593,7 +593,7 @@ int lxc_terminal_allocate(struct lxc_conf *conf, int sockfd, int *ttyreq)
                if (*ttyreq > ttys->max)
                        goto out;
 
-               if (ttys->tty[*ttyreq - 1].busy)
+               if (ttys->tty[*ttyreq - 1].busy >= 0)
                        goto out;
 
                /* The requested tty is available. */
@@ -602,7 +602,7 @@ int lxc_terminal_allocate(struct lxc_conf *conf, int sockfd, int *ttyreq)
        }
 
        /* Search for next available tty, fixup index tty1 => [0]. */
-       for (ttynum = 1; ttynum <= ttys->max && ttys->tty[ttynum - 1].busy; ttynum++) {
+       for (ttynum = 1; ttynum <= ttys->max && ttys->tty[ttynum - 1].busy >= 0; ttynum++) {
                ;
        }
 
@@ -628,7 +628,7 @@ void lxc_terminal_free(struct lxc_conf *conf, int fd)
 
        for (i = 0; i < ttys->max; i++)
                if (ttys->tty[i].busy == fd)
-                       ttys->tty[i].busy = 0;
+                       ttys->tty[i].busy = -1;
 
        if (terminal->proxy.busy != fd)
                return;