summaryrefslogtreecommitdiff
path: root/gtk/channel-smartcard.c
diff options
context:
space:
mode:
authorChristophe Fergeau <cfergeau@redhat.com>2011-06-17 18:59:51 +0200
committerMarc-André Lureau <marcandre.lureau@gmail.com>2011-06-23 20:01:09 +0200
commite5d1faa7c2448e10aa421ac9f401dd4c0a54f473 (patch)
tree67e2174c9af36ce9f0c0807352d055f9d0488ef6 /gtk/channel-smartcard.c
parentc384c4f22197a5e167565f5c56482f7354fec2b6 (diff)
don't always serialize messages sent to the server
The communication between spice clients and servers on the smartcard channel can be initiated either by the client or by the server. It's initiated by the client for smartcard reader events (reader hot(un)plug, card insertion/removal), or it can be initiated by the server when it wants to query the certificates available on the smartcard. When communication is initiated by the client, we want to serialize the messages we sent, ie we don't want to send a message if we haven't received yet the answer to the previous message. However, when it's the server which initiates the communication, we don't want to use this serializing mechanism. This commit adds a "serialize_msg" boolean to be able to disable message sending serialization as needed.
Diffstat (limited to 'gtk/channel-smartcard.c')
-rw-r--r--gtk/channel-smartcard.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/gtk/channel-smartcard.c b/gtk/channel-smartcard.c
index 5604638..770611a 100644
--- a/gtk/channel-smartcard.c
+++ b/gtk/channel-smartcard.c
@@ -253,10 +253,16 @@ smartcard_message_complete_in_flight(SpiceSmartCardChannel *channel)
static void smartcard_message_send(SpiceSmartCardChannel *channel,
VSCMsgType msg_type,
- spice_msg_out *msg_out)
+ spice_msg_out *msg_out, gboolean queue)
{
SpiceSmartCardChannelMessage *message;
+ if (!queue) {
+ spice_msg_out_send(msg_out);
+ spice_msg_out_unref(msg_out);
+ return;
+ }
+
message = smartcard_message_new(msg_type, msg_out);
if (channel->priv->in_flight_message == NULL) {
g_assert(g_queue_is_empty(channel->priv->message_queue));
@@ -270,7 +276,8 @@ static void smartcard_message_send(SpiceSmartCardChannel *channel,
static void
send_msg_generic_with_data(SpiceSmartCardChannel *channel, VReader *reader,
VSCMsgType msg_type,
- const uint8_t *data, gsize data_len)
+ const uint8_t *data, gsize data_len,
+ gboolean serialize_msg)
{
spice_msg_out *msg_out;
VSCMsgHeader header = {
@@ -290,13 +297,13 @@ send_msg_generic_with_data(SpiceSmartCardChannel *channel, VReader *reader,
spice_marshaller_add(msg_out->marshaller, data, data_len);
}
- smartcard_message_send(channel, msg_type, msg_out);
+ smartcard_message_send(channel, msg_type, msg_out, serialize_msg);
}
static void send_msg_generic(SpiceSmartCardChannel *channel, VReader *reader,
VSCMsgType msg_type)
{
- send_msg_generic_with_data(channel, reader, msg_type, NULL, 0);
+ send_msg_generic_with_data(channel, reader, msg_type, NULL, 0, TRUE);
}
static void send_msg_atr(SpiceSmartCardChannel *channel, VReader *reader)
@@ -307,7 +314,7 @@ static void send_msg_atr(SpiceSmartCardChannel *channel, VReader *reader)
g_assert(vreader_get_id(reader) != VSCARD_UNDEFINED_READER_ID);
vreader_power_on(reader, atr, &atr_len);
- send_msg_generic_with_data(channel, reader, VSC_ATR, atr, atr_len);
+ send_msg_generic_with_data(channel, reader, VSC_ATR, atr, atr_len, TRUE);
}
static void reader_added_cb(SpiceSmartCardManager *manager, VReader *reader,
@@ -320,7 +327,7 @@ static void reader_added_cb(SpiceSmartCardManager *manager, VReader *reader,
g_list_append(channel->priv->pending_reader_additions, reader);
send_msg_generic_with_data(channel, reader, VSC_ReaderAdd,
- (uint8_t*)reader_name, strlen(reader_name));
+ (uint8_t*)reader_name, strlen(reader_name), TRUE);
}
static void reader_removed_cb(SpiceSmartCardManager *manager, VReader *reader,
@@ -443,14 +450,14 @@ static void handle_smartcard_msg(SpiceChannel *channel, spice_msg_in *in)
if (reader_status == VREADER_OK) {
send_msg_generic_with_data(SPICE_SMARTCARD_CHANNEL(channel),
reader, VSC_APDU,
- data_out, data_out_len);
+ data_out, data_out_len, FALSE);
} else {
uint32_t error_code;
error_code = GUINT32_TO_LE(reader_status);
send_msg_generic_with_data(SPICE_SMARTCARD_CHANNEL(channel),
reader, VSC_Error,
(uint8_t*)&error_code,
- sizeof (error_code));
+ sizeof (error_code), FALSE);
}
break;
}