summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Fergeau <cfergeau@redhat.com>2019-02-08 10:43:33 +0100
committerChristophe Fergeau <cfergeau@redhat.com>2019-02-08 17:27:16 +0100
commitbde7d01cfe26e2fd39dd6d32c52127a7621644da (patch)
treec2249879cb3b080bbb1f35dc90fa2f23cf77d0fc
parentc0ac6a58a8ff409ebefe21a98caf8f1865cba474 (diff)
Store RedChannelClient in RedCharDeviceClient
Most subclasses are doing this anyway, so we can as well do it in the main one.
-rw-r--r--server/char-device.c10
-rw-r--r--server/char-device.h2
-rw-r--r--server/reds.c4
-rw-r--r--server/smartcard.c2
-rw-r--r--server/spicevmc.c2
5 files changed, 12 insertions, 8 deletions
diff --git a/server/char-device.c b/server/char-device.c
index 040b9114..9f40d2b7 100644
--- a/server/char-device.c
+++ b/server/char-device.c
@@ -50,6 +50,7 @@ typedef struct RedCharDeviceClient RedCharDeviceClient;
struct RedCharDeviceClient {
RedCharDevice *dev;
RedClient *client;
+ RedChannelClient *rcc;
int do_flow_control;
uint64_t num_client_tokens;
uint64_t num_client_tokens_free; /* client messages that were consumed by the device */
@@ -703,16 +704,18 @@ void red_char_device_destroy(RedCharDevice *char_dev)
g_object_unref(char_dev);
}
-static RedCharDeviceClient *red_char_device_client_new(RedClient *client,
+static RedCharDeviceClient *red_char_device_client_new(RedChannelClient *rcc,
int do_flow_control,
uint32_t max_send_queue_size,
uint32_t num_client_tokens,
uint32_t num_send_tokens)
{
+ RedClient *client = red_channel_client_get_client(rcc);
RedCharDeviceClient *dev_client;
dev_client = g_new0(RedCharDeviceClient, 1);
dev_client->client = client;
+ dev_client->rcc = rcc;
dev_client->send_queue = g_queue_new();
dev_client->max_send_queue_size = max_send_queue_size;
dev_client->do_flow_control = do_flow_control;
@@ -736,7 +739,7 @@ static RedCharDeviceClient *red_char_device_client_new(RedClient *client,
}
bool red_char_device_client_add(RedCharDevice *dev,
- RedClient *client,
+ RedChannelClient *rcc,
int do_flow_control,
uint32_t max_send_queue_size,
uint32_t num_client_tokens,
@@ -744,6 +747,7 @@ bool red_char_device_client_add(RedCharDevice *dev,
int wait_for_migrate_data)
{
RedCharDeviceClient *dev_client;
+ RedClient *client = red_channel_client_get_client(rcc);
spice_assert(dev);
spice_assert(client);
@@ -757,7 +761,7 @@ bool red_char_device_client_add(RedCharDevice *dev,
dev->priv->wait_for_migrate_data = wait_for_migrate_data;
spice_debug("char device %p, client %p", dev, client);
- dev_client = red_char_device_client_new(client, do_flow_control,
+ dev_client = red_char_device_client_new(rcc, do_flow_control,
max_send_queue_size,
num_client_tokens,
num_send_tokens);
diff --git a/server/char-device.h b/server/char-device.h
index 893d3e4b..2b68c5c8 100644
--- a/server/char-device.h
+++ b/server/char-device.h
@@ -188,7 +188,7 @@ void red_char_device_reset(RedCharDevice *dev);
/* max_send_queue_size = how many messages we can read from the device and enqueue for this client,
* when we have tokens for other clients and no tokens for this one */
bool red_char_device_client_add(RedCharDevice *dev,
- RedClient *client,
+ RedChannelClient *rcc,
int do_flow_control,
uint32_t max_send_queue_size,
uint32_t num_client_tokens,
diff --git a/server/reds.c b/server/reds.c
index 86f020a8..bb6c353d 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -1170,7 +1170,7 @@ void reds_on_main_agent_start(RedsState *reds, MainChannelClient *mcc, uint32_t
int client_added;
client_added = red_char_device_client_add(dev_state,
- client,
+ rcc,
TRUE, /* flow control */
REDS_VDI_PORT_NUM_RECEIVE_BUFFS,
REDS_AGENT_WINDOW_SIZE,
@@ -3196,7 +3196,7 @@ static RedCharDevice *attach_to_red_agent(RedsState *reds, SpiceCharDeviceInstan
int client_added;
client_added = red_char_device_client_add(RED_CHAR_DEVICE(dev),
- reds_get_client(reds),
+ RED_CHANNEL_CLIENT(red_client_get_main(reds_get_client(reds))),
TRUE, /* flow control */
REDS_VDI_PORT_NUM_RECEIVE_BUFFS,
REDS_AGENT_WINDOW_SIZE,
diff --git a/server/smartcard.c b/server/smartcard.c
index 34cfca23..780a587a 100644
--- a/server/smartcard.c
+++ b/server/smartcard.c
@@ -311,7 +311,7 @@ void smartcard_char_device_attach_client(SpiceCharDeviceInstance *char_device,
dev->priv->scc = scc;
smartcard_channel_client_set_char_device(scc, dev);
client_added = red_char_device_client_add(RED_CHAR_DEVICE(dev),
- red_channel_client_get_client(RED_CHANNEL_CLIENT(scc)),
+ RED_CHANNEL_CLIENT(scc),
FALSE, /* no flow control yet */
0, /* send queue size */
~0,
diff --git a/server/spicevmc.c b/server/spicevmc.c
index 51550c1a..2524f68d 100644
--- a/server/spicevmc.c
+++ b/server/spicevmc.c
@@ -782,7 +782,7 @@ static void spicevmc_connect(RedChannel *channel, RedClient *client,
spicevmc_port_send_init(rcc);
}
- if (!red_char_device_client_add(vmc_channel->chardev, client, FALSE, 0, ~0, ~0,
+ if (!red_char_device_client_add(vmc_channel->chardev, rcc, FALSE, 0, ~0, ~0,
red_channel_client_is_waiting_for_migrate_data(rcc))) {
spice_warning("failed to add client to spicevmc");
red_channel_client_disconnect(rcc);