Skip to contentSkip to conversation

Repost: Bug with select?

DISCUSSION Manfred Spraul 1 participant 1 message Jul 28, 2003 Char and misc drivers

lore
Share & tools
lore
#0 lore raw

Hi Eli,

The problem is normal_poll in drivers/char/n_tty.c:

Quoted 2 lines

if (tty->driver->chars_in_buffer(tty) < WAKEUP_CHARS)

               mask |= POLLOUT | POLLWRNORM;

It assumes that a following write will succeed if less than 256 bytes are in the write buffer right now. This assumption is wrong for con_write_room: if the console is stopped, it returns 0 bytes buffer size (con_write_room()). Dito for pty_write_room.

The attached patch fixes your test case, but I don't understand tty devices good enough to guarantee anything.

--
Manfred

drivers/char/n_tty.c +2 -1
@@ -1251,7 +1251,8 @@
 		else
 			tty->minimum_to_wake = 1;
 	}
-	if (tty->driver->chars_in_buffer(tty) < WAKEUP_CHARS)
+	if (tty->driver->chars_in_buffer(tty) < WAKEUP_CHARS &&
+			tty->driver->write_room(tty) > 0)
 		mask |= POLLOUT | POLLWRNORM;
 	return mask;
 }