Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 221900
b: refs/heads/master
c: e045fec
h: refs/heads/master
v: v3
  • Loading branch information
Jiri Olsa authored and Greg Kroah-Hartman committed Nov 9, 2010
1 parent 8dea15e commit c64d7f4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c9bd9d01db02319c33767da5ee310ea37afda059
refs/heads/master: e045fec48970df84647a47930fcf7a22ff7229c0
14 changes: 12 additions & 2 deletions trunk/drivers/tty/tty_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,8 @@ static void flush_to_ldisc(struct work_struct *work)
spin_lock_irqsave(&tty->buf.lock, flags);

if (!test_and_set_bit(TTY_FLUSHING, &tty->flags)) {
struct tty_buffer *head;
struct tty_buffer *head, *tail = tty->buf.tail;
int seen_tail = 0;
while ((head = tty->buf.head) != NULL) {
int count;
char *char_buf;
Expand All @@ -423,6 +424,15 @@ static void flush_to_ldisc(struct work_struct *work)
if (!count) {
if (head->next == NULL)
break;
/*
There's a possibility tty might get new buffer
added during the unlock window below. We could
end up spinning in here forever hogging the CPU
completely. To avoid this let's have a rest each
time we processed the tail buffer.
*/
if (tail == head)
seen_tail = 1;
tty->buf.head = head->next;
tty_buffer_free(tty, head);
continue;
Expand All @@ -432,7 +442,7 @@ static void flush_to_ldisc(struct work_struct *work)
line discipline as we want to empty the queue */
if (test_bit(TTY_FLUSHPENDING, &tty->flags))
break;
if (!tty->receive_room) {
if (!tty->receive_room || seen_tail) {
schedule_delayed_work(&tty->buf.work, 1);
break;
}
Expand Down

0 comments on commit c64d7f4

Please sign in to comment.