Unverified Commit 92ef1f8a by Christian Brauner Committed by GitHub

Merge pull request #3214 from Rachid-Koucha/patch-1

"busy" field init to -1 instead of 0
parents 6b3dccea 730aaf46
......@@ -1006,7 +1006,7 @@ int lxc_allocate_ttys(struct lxc_conf *conf)
SYSWARN("Failed to set FD_CLOEXEC flag on slave fd %d of "
"tty device \"%s\"", tty->slave, tty->name);
tty->busy = 0;
tty->busy = -1;
}
INFO("Finished creating %zu tty devices", ttys->max);
......
......@@ -1526,11 +1526,11 @@ static int lxc_recv_ttys_from_child(struct lxc_handler *handler)
break;
tty = &ttys->tty[i];
tty->busy = 0;
tty->busy = -1;
tty->master = ttyfds[0];
tty->slave = ttyfds[1];
TRACE("Received pty with master fd %d and slave fd %d from "
"parent", tty->master, tty->slave);
"child", tty->master, tty->slave);
}
if (ret < 0)
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment