[Spice-commits] server/char-device.c
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Aug 2 10:15:19 UTC 2019
server/char-device.c | 42 +++++++++++++++++++-----------------------
1 file changed, 19 insertions(+), 23 deletions(-)
New commits:
commit a21de341733acdc4374a41b0269dc368875bb222
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Thu May 30 06:02:32 2019 +0100
char-device: Pull more code into red_char_device_send_to_client_tokens_absorb
The 2 callers red_char_device_send_to_client_tokens_set and
red_char_device_send_to_client_tokens_add are doing mostly
the same thing so put common code to
red_char_device_send_to_client_tokens_absorb.
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Victor Toso <victortoso at redhat.com>
diff --git a/server/char-device.c b/server/char-device.c
index 2ddd34ef..b0b4ef6c 100644
--- a/server/char-device.c
+++ b/server/char-device.c
@@ -368,10 +368,24 @@ static void red_char_device_client_send_queue_push(RedCharDeviceClient *dev_clie
}
}
-static void red_char_device_send_to_client_tokens_absorb(RedCharDeviceClient *dev_client,
- uint32_t tokens)
+static void
+red_char_device_send_to_client_tokens_absorb(RedCharDevice *dev,
+ RedClient *client,
+ uint32_t tokens,
+ bool reset)
{
- RedCharDevice *dev = dev_client->dev;
+ RedCharDeviceClient *dev_client;
+
+ dev_client = red_char_device_client_find(dev, client);
+
+ if (!dev_client) {
+ spice_error("client wasn't found dev %p client %p", dev, client);
+ return;
+ }
+
+ if (reset) {
+ dev_client->num_send_tokens = 0;
+ }
dev_client->num_send_tokens += tokens;
if (g_queue_get_length(dev_client->send_queue)) {
@@ -394,32 +408,14 @@ void red_char_device_send_to_client_tokens_add(RedCharDevice *dev,
RedClient *client,
uint32_t tokens)
{
- RedCharDeviceClient *dev_client;
-
- dev_client = red_char_device_client_find(dev, client);
-
- if (!dev_client) {
- spice_error("client wasn't found dev %p client %p", dev, client);
- return;
- }
- red_char_device_send_to_client_tokens_absorb(dev_client, tokens);
+ red_char_device_send_to_client_tokens_absorb(dev, client, tokens, false);
}
void red_char_device_send_to_client_tokens_set(RedCharDevice *dev,
RedClient *client,
uint32_t tokens)
{
- RedCharDeviceClient *dev_client;
-
- dev_client = red_char_device_client_find(dev, client);
-
- if (!dev_client) {
- spice_error("client wasn't found dev %p client %p", dev, client);
- return;
- }
-
- dev_client->num_send_tokens = 0;
- red_char_device_send_to_client_tokens_absorb(dev_client, tokens);
+ red_char_device_send_to_client_tokens_absorb(dev, client, tokens, true);
}
/**************************
More information about the Spice-commits
mailing list