summaryrefslogtreecommitdiffstats
path: root/server/char-device.c
diff options
context:
space:
mode:
Diffstat (limited to 'server/char-device.c')
-rw-r--r--server/char-device.c34
1 files changed, 19 insertions, 15 deletions
diff --git a/server/char-device.c b/server/char-device.c
index 6c64480c..c9265e29 100644
--- a/server/char-device.c
+++ b/server/char-device.c
@@ -67,7 +67,7 @@ struct SpiceCharDeviceState {
SpiceCharDeviceCallbacks cbs;
void *opaque;
- void *reds;
+ RedsState *reds;
};
enum {
@@ -146,7 +146,7 @@ static void spice_char_device_client_free(SpiceCharDeviceState *dev,
RingItem *item, *next;
if (dev_client->wait_for_tokens_timer) {
- reds_get_core_interface(reds)->timer_remove(dev_client->wait_for_tokens_timer);
+ reds_get_core_interface(dev->reds)->timer_remove(dev_client->wait_for_tokens_timer);
}
spice_char_device_client_send_queue_free(dev, dev_client);
@@ -252,7 +252,7 @@ static void spice_char_device_add_msg_to_client_queue(SpiceCharDeviceClientState
ring_add(&dev_client->send_queue, &msg_item->link);
dev_client->send_queue_size++;
if (!dev_client->wait_for_tokens_started) {
- reds_get_core_interface(reds)->timer_start(dev_client->wait_for_tokens_timer,
+ reds_get_core_interface(dev->reds)->timer_start(dev_client->wait_for_tokens_timer,
SPICE_CHAR_DEVICE_WAIT_TOKENS_TIMEOUT);
dev_client->wait_for_tokens_started = TRUE;
}
@@ -352,6 +352,7 @@ static void spice_char_device_client_send_queue_push(SpiceCharDeviceClientState
static void spice_char_device_send_to_client_tokens_absorb(SpiceCharDeviceClientState *dev_client,
uint32_t tokens)
{
+ SpiceCharDeviceState *dev = dev_client->dev;
dev_client->num_send_tokens += tokens;
if (dev_client->send_queue_size) {
@@ -360,12 +361,12 @@ static void spice_char_device_send_to_client_tokens_absorb(SpiceCharDeviceClient
}
if (spice_char_device_can_send_to_client(dev_client)) {
- reds_get_core_interface(reds)->timer_cancel(dev_client->wait_for_tokens_timer);
+ reds_get_core_interface(dev->reds)->timer_cancel(dev_client->wait_for_tokens_timer);
dev_client->wait_for_tokens_started = FALSE;
spice_char_device_read_from_device(dev_client->dev);
} else if (dev_client->send_queue_size) {
- reds_get_core_interface(reds)->timer_start(dev_client->wait_for_tokens_timer,
- SPICE_CHAR_DEVICE_WAIT_TOKENS_TIMEOUT);
+ reds_get_core_interface(dev->reds)->timer_start(dev_client->wait_for_tokens_timer,
+ SPICE_CHAR_DEVICE_WAIT_TOKENS_TIMEOUT);
dev_client->wait_for_tokens_started = TRUE;
}
}
@@ -441,7 +442,7 @@ static int spice_char_device_write_to_device(SpiceCharDeviceState *dev)
spice_char_device_state_ref(dev);
if (dev->write_to_dev_timer) {
- reds_get_core_interface(reds)->timer_cancel(dev->write_to_dev_timer);
+ reds_get_core_interface(dev->reds)->timer_cancel(dev->write_to_dev_timer);
}
sif = SPICE_CONTAINEROF(dev->sin->base.sif, SpiceCharDeviceInterface, base);
@@ -478,8 +479,8 @@ static int spice_char_device_write_to_device(SpiceCharDeviceState *dev)
if (dev->running) {
if (dev->cur_write_buf) {
if (dev->write_to_dev_timer) {
- reds_get_core_interface(reds)->timer_start(dev->write_to_dev_timer,
- CHAR_DEVICE_WRITE_TO_TIMEOUT);
+ reds_get_core_interface(dev->reds)->timer_start(dev->write_to_dev_timer,
+ CHAR_DEVICE_WRITE_TO_TIMEOUT);
}
} else {
spice_assert(ring_is_empty(&dev->write_queue));
@@ -495,7 +496,7 @@ static void spice_char_dev_write_retry(void *opaque)
SpiceCharDeviceState *dev = opaque;
if (dev->write_to_dev_timer) {
- reds_get_core_interface(reds)->timer_cancel(dev->write_to_dev_timer);
+ reds_get_core_interface(dev->reds)->timer_cancel(dev->write_to_dev_timer);
}
spice_char_device_write_to_device(dev);
}
@@ -637,6 +638,7 @@ void spice_char_device_write_buffer_release(SpiceCharDeviceState *dev,
********************************/
SpiceCharDeviceState *spice_char_device_state_create(SpiceCharDeviceInstance *sin,
+ RedsState *reds,
uint32_t client_tokens_interval,
uint32_t self_tokens,
SpiceCharDeviceCallbacks *cbs,
@@ -652,6 +654,7 @@ SpiceCharDeviceState *spice_char_device_state_create(SpiceCharDeviceInstance *si
char_dev = spice_new0(SpiceCharDeviceState, 1);
char_dev->sin = sin;
+ char_dev->reds = reds;
char_dev->cbs = *cbs;
char_dev->opaque = opaque;
char_dev->client_tokens_interval = client_tokens_interval;
@@ -710,9 +713,9 @@ static void spice_char_device_state_unref(SpiceCharDeviceState *char_dev)
void spice_char_device_state_destroy(SpiceCharDeviceState *char_dev)
{
- reds_on_char_device_state_destroy(reds, char_dev);
+ reds_on_char_device_state_destroy(char_dev->reds, char_dev);
if (char_dev->write_to_dev_timer) {
- reds_get_core_interface(reds)->timer_remove(char_dev->write_to_dev_timer);
+ reds_get_core_interface(char_dev->reds)->timer_remove(char_dev->write_to_dev_timer);
}
write_buffers_queue_free(&char_dev->write_queue);
write_buffers_queue_free(&char_dev->write_bufs_pool);
@@ -762,8 +765,9 @@ int spice_char_device_client_add(SpiceCharDeviceState *dev,
dev_client->max_send_queue_size = max_send_queue_size;
dev_client->do_flow_control = do_flow_control;
if (do_flow_control) {
- dev_client->wait_for_tokens_timer = reds_get_core_interface(reds)->timer_add(device_client_wait_for_tokens_timeout,
- dev_client);
+ dev_client->wait_for_tokens_timer =
+ reds_get_core_interface(dev->reds)->timer_add(device_client_wait_for_tokens_timeout,
+ dev_client);
if (!dev_client->wait_for_tokens_timer) {
spice_error("failed to create wait for tokens timer");
}
@@ -822,7 +826,7 @@ void spice_char_device_stop(SpiceCharDeviceState *dev)
dev->running = FALSE;
dev->active = FALSE;
if (dev->write_to_dev_timer) {
- reds_get_core_interface(reds)->timer_cancel(dev->write_to_dev_timer);
+ reds_get_core_interface(dev->reds)->timer_cancel(dev->write_to_dev_timer);
}
}