[Spice-devel] [PATCH] server/smartcard: register channel only when hardware is available
Christophe Fergeau
cfergeau at redhat.com
Tue Jul 5 02:17:21 PDT 2011
I think you should just commit this since it fixes a bug anyway.
Christophe
On Wed, Jun 29, 2011 at 02:14:07PM +0200, Alon Levy wrote:
> ---
> server/reds.c | 4 ----
> server/smartcard.c | 11 +++++++++--
> 2 files changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/server/reds.c b/server/reds.c
> index e917a7c..7dc4252 100644
> --- a/server/reds.c
> +++ b/server/reds.c
> @@ -3533,10 +3533,6 @@ static int do_spice_init(SpiceCoreInterface *core_interface)
> reds->main_channel = NULL;
> inputs_init();
>
> -#ifdef USE_SMARTCARD
> - smartcard_channel_init();
> -#endif
> -
> reds->mouse_mode = SPICE_MOUSE_MODE_SERVER;
> atexit(reds_exit);
> return 0;
> diff --git a/server/smartcard.c b/server/smartcard.c
> index f948e5b..49bf3cb 100644
> --- a/server/smartcard.c
> +++ b/server/smartcard.c
> @@ -81,6 +81,7 @@ static void smartcard_on_message_from_device(
> SmartCardChannel *smartcard_channel, VSCMsgHeader *vheader);
> static SmartCardDeviceState* smartcard_device_state_new();
> static void smartcard_device_state_free(SmartCardDeviceState* st);
> +static void smartcard_register_channel(void);
>
> void smartcard_char_device_wakeup(SpiceCharDeviceInstance *sin)
> {
> @@ -166,6 +167,7 @@ static int smartcard_char_device_add_to_readers(SpiceCharDeviceInstance *char_de
> }
> state->reader_id = g_smartcard_readers.num;
> g_smartcard_readers.sin[g_smartcard_readers.num++] = char_device;
> + smartcard_register_channel();
> return 0;
> }
>
> @@ -534,10 +536,16 @@ static void smartcard_migrate(Channel *channel)
> {
> }
>
> -void smartcard_channel_init(void)
> +static void smartcard_register_channel(void)
> {
> Channel *channel;
> + static int registered = 0;
>
> + if (registered) {
> + return;
> + }
> + red_printf("registering smartcard channel");
> + registered = 1;
> channel = spice_new0(Channel, 1);
> channel->type = SPICE_CHANNEL_SMARTCARD;
> channel->link = smartcard_link;
> @@ -545,4 +553,3 @@ void smartcard_channel_init(void)
> channel->migrate = smartcard_migrate;
> reds_register_channel(channel);
> }
> -
> --
> 1.7.5.4
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20110705/0f4c7cf3/attachment.pgp>
More information about the Spice-devel
mailing list