Skip to content

Commit

Permalink
Revert ""busy" field init to -1 instead of 0"
Browse files Browse the repository at this point in the history
  • Loading branch information
brauner committed Dec 6, 2019
1 parent 92ef1f8 commit 5c0fe2a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/lxc/conf.c
Expand Up @@ -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 = -1;
tty->busy = 0;
}

INFO("Finished creating %zu tty devices", ttys->max);
Expand Down
4 changes: 2 additions & 2 deletions src/lxc/start.c
Expand Up @@ -1526,11 +1526,11 @@ static int lxc_recv_ttys_from_child(struct lxc_handler *handler)
break;

tty = &ttys->tty[i];
tty->busy = -1;
tty->busy = 0;
tty->master = ttyfds[0];
tty->slave = ttyfds[1];
TRACE("Received pty with master fd %d and slave fd %d from "
"child", tty->master, tty->slave);
"parent", tty->master, tty->slave);
}

if (ret < 0)
Expand Down
6 changes: 3 additions & 3 deletions src/lxc/terminal.c
Expand Up @@ -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 >= 0)
if (ttys->tty[*ttyreq - 1].busy)
goto out;

/* The requested tty is available. */
Expand All @@ -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 >= 0; ttynum++) {
for (ttynum = 1; ttynum <= ttys->max && ttys->tty[ttynum - 1].busy; ttynum++) {
;
}

Expand All @@ -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 = -1;
ttys->tty[i].busy = 0;

if (terminal->proxy.busy != fd)
return;
Expand Down

0 comments on commit 5c0fe2a

Please sign in to comment.