summaryrefslogtreecommitdiffstats
path: root/server/char_device.c
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2013-03-29 10:02:35 +0100
committerHans de Goede <hdegoede@redhat.com>2013-03-29 10:05:11 +0100
commite3c6f793f7592bce4778986b2e28f9e7f2c56589 (patch)
treeb3e9f95fa839ab92ed5219507b09c1a191e4b8b4 /server/char_device.c
parent25f84a2d6e0a007a08f3907ce98d535d785b12d5 (diff)
downloadspice-e3c6f793f7592bce4778986b2e28f9e7f2c56589.tar.gz
spice-e3c6f793f7592bce4778986b2e28f9e7f2c56589.tar.xz
spice-e3c6f793f7592bce4778986b2e28f9e7f2c56589.zip
char_device: Properly update buffer status when leaving the write loop on stop
Before this patch the write-loop in spice_char_device_write_to_device would break on running becoming 0, after having written some data, without updating the buffer status, causing the same data to be written *again* when started. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'server/char_device.c')
-rw-r--r--server/char_device.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/server/char_device.c b/server/char_device.c
index e07eda1f..368c9bc0 100644
--- a/server/char_device.c
+++ b/server/char_device.c
@@ -438,7 +438,7 @@ static int spice_char_device_write_to_device(SpiceCharDeviceState *dev)
core->timer_cancel(dev->write_to_dev_timer);
sif = SPICE_CONTAINEROF(dev->sin->base.sif, SpiceCharDeviceInterface, base);
- while (1) {
+ while (dev->running) {
uint32_t write_len;
if (!dev->cur_write_buf) {
@@ -454,9 +454,6 @@ static int spice_char_device_write_to_device(SpiceCharDeviceState *dev)
write_len = dev->cur_write_buf->buf + dev->cur_write_buf->buf_used -
dev->cur_write_buf_pos;
n = sif->write(dev->sin, dev->cur_write_buf_pos, write_len);
- if (!dev->running) {
- break;
- }
if (n <= 0) {
break;
}