n_tty: Encapsulate minimum_to_wake within N_TTY
minimum_to_wake is unique to N_TTY processing, and belongs in per-ldisc data. Add the ldisc method, ldisc_ops::fasync(), to notify line disciplines when signal-driven I/O is enabled or disabled. When enabled for N_TTY (by fcntl(F_SETFL, O_ASYNC)), blocking reader/polls will be woken for any readable input. When disabled, blocking reader/polls are not woken until the read buffer is full. Canonical mode (L_ICANON(tty), n_tty_data::icanon) is not affected by the minimum_to_wake setting. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
a630fbfbb1
commit
f6c8dbe6e5
@@ -2138,6 +2138,7 @@ static unsigned int tty_poll(struct file *filp, poll_table *wait)
|
||||
static int __tty_fasync(int fd, struct file *filp, int on)
|
||||
{
|
||||
struct tty_struct *tty = file_tty(filp);
|
||||
struct tty_ldisc *ldisc;
|
||||
unsigned long flags;
|
||||
int retval = 0;
|
||||
|
||||
@@ -2148,11 +2149,17 @@ static int __tty_fasync(int fd, struct file *filp, int on)
|
||||
if (retval <= 0)
|
||||
goto out;
|
||||
|
||||
ldisc = tty_ldisc_ref(tty);
|
||||
if (ldisc) {
|
||||
if (ldisc->ops->fasync)
|
||||
ldisc->ops->fasync(tty, on);
|
||||
tty_ldisc_deref(ldisc);
|
||||
}
|
||||
|
||||
if (on) {
|
||||
enum pid_type type;
|
||||
struct pid *pid;
|
||||
if (!waitqueue_active(&tty->read_wait))
|
||||
tty->minimum_to_wake = 1;
|
||||
|
||||
spin_lock_irqsave(&tty->ctrl_lock, flags);
|
||||
if (tty->pgrp) {
|
||||
pid = tty->pgrp;
|
||||
@@ -2165,13 +2172,7 @@ static int __tty_fasync(int fd, struct file *filp, int on)
|
||||
spin_unlock_irqrestore(&tty->ctrl_lock, flags);
|
||||
retval = __f_setown(filp, pid, type, 0);
|
||||
put_pid(pid);
|
||||
if (retval)
|
||||
goto out;
|
||||
} else {
|
||||
if (!tty->fasync && !waitqueue_active(&tty->read_wait))
|
||||
tty->minimum_to_wake = N_TTY_BUF_SIZE;
|
||||
}
|
||||
retval = 0;
|
||||
out:
|
||||
return retval;
|
||||
}
|
||||
|
Reference in New Issue
Block a user