summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2013-03-29 10:07:26 +0100
committerHans de Goede <hdegoede@redhat.com>2013-03-29 10:07:26 +0100
commitbaa7cab700155201abde86e31018e1a8f28dc330 (patch)
treee359e4ba263a7f2c222d86a70680fc7f401535cc /server
parent3d775594b506e4199e850b51af8de762902b849a (diff)
downloadspice-baa7cab700155201abde86e31018e1a8f28dc330.tar.gz
spice-baa7cab700155201abde86e31018e1a8f28dc330.tar.xz
spice-baa7cab700155201abde86e31018e1a8f28dc330.zip
char_device: Don't set active when stopped and don't access dev after unref
2 closely related changes in one: 1) When leaving the read or write loop because the chardev has been stopped active should not be updated. It has been set to FALSE by spice_char_device_stop and should stay FALSE 2) The updating of dev->active should be done *before* unref-ing dev Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'server')
-rw-r--r--server/char_device.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/server/char_device.c b/server/char_device.c
index 63afee11..f500f04f 100644
--- a/server/char_device.c
+++ b/server/char_device.c
@@ -320,8 +320,10 @@ static int spice_char_device_read_from_device(SpiceCharDeviceState *dev)
max_send_tokens--;
}
dev->during_read_from_device = 0;
+ if (dev->running) {
+ dev->active = dev->active || did_read;
+ }
spice_char_device_state_unref(dev);
- dev->active = dev->active || did_read;
return did_read;
}
@@ -475,9 +477,9 @@ static int spice_char_device_write_to_device(SpiceCharDeviceState *dev)
} else {
spice_assert(ring_is_empty(&dev->write_queue));
}
+ dev->active = dev->active || total;
}
spice_char_device_state_unref(dev);
- dev->active = dev->active || total;
return total;
}