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>
This commit is contained in:
Hans de Goede 2013-03-29 10:02:35 +01:00
parent 25f84a2d6e
commit e3c6f793f7

View File

@ -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;
}