[spice-server 3/6] Make RedCharDeviceWriteBuffer::client private

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Christophe Fergeau <cfergeau@xxxxxxxxxx>
---
 server/char-device.c | 22 ++++++++++++----------
 server/char-device.h |  3 ---
 2 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/server/char-device.c b/server/char-device.c
index ff9d2f0..f7e40aa 100644
--- a/server/char-device.c
+++ b/server/char-device.c
@@ -33,6 +33,8 @@
 
 struct RedCharDeviceWriteBufferPrivate {
     int origin;
+    RedClient *client; /* The client that sent the message to the device.
+                          NULL if the server created the message */
 };
 
 typedef struct RedCharDeviceClient RedCharDeviceClient;
@@ -166,7 +168,7 @@ static void red_char_device_write_buffer_pool_add(RedCharDevice *dev,
         dev->priv->cur_pool_size < MAX_POOL_SIZE) {
         buf->buf_used = 0;
         buf->priv->origin = WRITE_BUFFER_ORIGIN_NONE;
-        buf->client = NULL;
+        buf->priv->client = NULL;
         dev->priv->cur_pool_size += buf->buf_size;
         g_queue_push_head(&dev->priv->write_bufs_pool, buf);
         return;
@@ -194,7 +196,7 @@ static void red_char_device_client_free(RedCharDevice *dev,
         next = l->next;
 
         if (write_buf->priv->origin == WRITE_BUFFER_ORIGIN_CLIENT &&
-            write_buf->client == dev_client->client) {
+            write_buf->priv->client == dev_client->client) {
             g_queue_delete_link(&dev->priv->write_queue, l);
             red_char_device_write_buffer_pool_add(dev, write_buf);
         }
@@ -202,9 +204,9 @@ static void red_char_device_client_free(RedCharDevice *dev,
     }
 
     if (dev->priv->cur_write_buf && dev->priv->cur_write_buf->priv->origin == WRITE_BUFFER_ORIGIN_CLIENT &&
-        dev->priv->cur_write_buf->client == dev_client->client) {
+        dev->priv->cur_write_buf->priv->client == dev_client->client) {
         dev->priv->cur_write_buf->priv->origin = WRITE_BUFFER_ORIGIN_NONE;
-        dev->priv->cur_write_buf->client = NULL;
+        dev->priv->cur_write_buf->priv->client = NULL;
     }
 
     dev->priv->clients = g_list_remove(dev->priv->clients, dev_client);
@@ -566,7 +568,7 @@ static RedCharDeviceWriteBuffer *__red_char_device_write_buffer_get(
                 red_char_device_handle_client_overflow(dev_client);
                 goto error;
             }
-            ret->client = client;
+            ret->priv->client = client;
             if (!migrated_data_tokens && dev_client->do_flow_control) {
                 dev_client->num_client_tokens--;
             }
@@ -628,8 +630,8 @@ void red_char_device_write_buffer_add(RedCharDevice *dev,
     spice_assert(dev);
     /* caller shouldn't add buffers for client that was removed */
     if (write_buf->priv->origin == WRITE_BUFFER_ORIGIN_CLIENT &&
-        !red_char_device_client_find(dev, write_buf->client)) {
-        spice_printerr("client not found: dev %p client %p", dev, write_buf->client);
+        !red_char_device_client_find(dev, write_buf->priv->client)) {
+        spice_printerr("client not found: dev %p client %p", dev, write_buf->priv->client);
         red_char_device_write_buffer_pool_add(dev, write_buf);
         return;
     }
@@ -649,7 +651,7 @@ void red_char_device_write_buffer_release(RedCharDevice *dev,
 
     int buf_origin = write_buf->priv->origin;
     uint32_t buf_token_price = write_buf->token_price;
-    RedClient *client = write_buf->client;
+    RedClient *client = write_buf->priv->client;
 
     if (!dev) {
         spice_printerr("no device. write buffer is freed");
@@ -905,7 +907,7 @@ void red_char_device_migrate_data_marshall(RedCharDevice *dev,
                                          );
         *write_to_dev_size_ptr += buf_remaining;
         if (dev->priv->cur_write_buf->priv->origin == WRITE_BUFFER_ORIGIN_CLIENT) {
-            spice_assert(dev->priv->cur_write_buf->client == dev_client->client);
+            spice_assert(dev->priv->cur_write_buf->priv->client == dev_client->client);
             (*write_to_dev_tokens_ptr) += dev->priv->cur_write_buf->token_price;
         }
     }
@@ -919,7 +921,7 @@ void red_char_device_migrate_data_marshall(RedCharDevice *dev,
                                          );
         *write_to_dev_size_ptr += write_buf->buf_used;
         if (write_buf->priv->origin == WRITE_BUFFER_ORIGIN_CLIENT) {
-            spice_assert(write_buf->client == dev_client->client);
+            spice_assert(write_buf->priv->client == dev_client->client);
             (*write_to_dev_tokens_ptr) += write_buf->token_price;
         }
     }
diff --git a/server/char-device.h b/server/char-device.h
index 6b34db7..272eae9 100644
--- a/server/char-device.h
+++ b/server/char-device.h
@@ -149,9 +149,6 @@ GType red_char_device_get_type(void) G_GNUC_CONST;
 struct RedCharDeviceWriteBufferPrivate;
 typedef struct RedCharDeviceWriteBufferPrivate RedCharDeviceWriteBufferPrivate;
 typedef struct RedCharDeviceWriteBuffer {
-    RedClient *client; /* The client that sent the message to the device.
-                          NULL if the server created the message */
-
     uint8_t *buf;
     uint32_t buf_size;
     uint32_t buf_used;
-- 
2.9.3

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]