|
|
e34bb01 |
Subject: virtio_console: Fix poll blocking even though there is data to read (version 2)
|
|
|
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 |
|
|
|
e34bb01 |
This causes poll() to block even though there is data ready to be read, this
|
|
|
e34bb01 |
patch fixes this by using port_has_data(port) instead of the
|
|
|
e34bb01 |
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)
|
|
|
e34bb01 |
+ if (port_has_data(port))
|
|
|
e34bb01 |
ret |= POLLIN | POLLRDNORM;
|
|
|
e34bb01 |
if (!will_write_block(port))
|
|
|
e34bb01 |
ret |= POLLOUT;
|