606af2d
Subject: virtio_console: Fix poll blocking even though there is data to read
e34bb01
From: Hans de Goede <hdegoede@redhat.com>
e34bb01
e34bb01
I found this while working on a Linux agent for spice, the symptom I was
e34bb01
seeing was select blocking on the spice vdagent virtio serial port even
e34bb01
though there were messages queued up there.
e34bb01
e34bb01
virtio_console's port_fops_poll checks port->inbuf != NULL to determine if
e34bb01
read won't block. However if an application reads enough bytes from inbuf
e34bb01
through port_fops_read, to empty the current port->inbuf, port->inbuf
e34bb01
will be NULL even though there may be buffers left in the virtqueue.
e34bb01
606af2d
This causes poll() to block even though there is data to be read, this patch
606af2d
fixes this by using the alredy defined will_read_block utility function
606af2d
instead of the port->inbuf != NULL check.
e34bb01
e34bb01
Signed-off-By: Hans de Goede <hdegoede@redhat.com>
e34bb01
diff -up linux-2.6.35.x86_64/drivers/char/virtio_console.c~ linux-2.6.35.x86_64/drivers/char/virtio_console.c
e34bb01
--- linux-2.6.35.x86_64/drivers/char/virtio_console.c~	2010-08-02 00:11:14.000000000 +0200
e34bb01
+++ linux-2.6.35.x86_64/drivers/char/virtio_console.c	2010-09-15 13:39:29.043505000 +0200
e34bb01
@@ -642,7 +642,7 @@ static unsigned int port_fops_poll(struc
e34bb01
 	poll_wait(filp, &port->waitqueue, wait);
e34bb01
 
e34bb01
 	ret = 0;
e34bb01
-	if (port->inbuf)
606af2d
+	if (!will_read_block(port))
e34bb01
 		ret |= POLLIN | POLLRDNORM;
e34bb01
 	if (!will_write_block(port))
e34bb01
 		ret |= POLLOUT;