Hi,

Sorry for being tiresome but thinking about this issue I think we have only two 
ways of going:
1.- pcsc-lite changes SCardReconnect to release the locks and perform as 
windows implementation does. This option changes how the software works right 
now and can trigger another problems in other projects that depend on it. 
Besides it wouldn't solve pcsc on mac (I think pcsc on mac forked an older 
pcsc-lite version, so I suppose it has the same behavior, SCardReconnect does 
not release the locks).
2.- opensc adds some "ifdef _WIN32" to add or not add the lock after a 
SCardReconnect. I suppose it would be something similar to the patch attached 
(comments are welcomed).
Ludovic, it is up to you. You can consider better than me which one is the 
better approach. If you think it is better to patch opensc to act differently 
depending windows or not windows I will try to submit a pull requests to opensc 
referencing bug #475.

Thank you very much in deep.



      From: Ricardo Martin <[email protected]>
 To: Talks about MUSCLE <[email protected]> 
 Sent: Tuesday, June 2, 2015 11:55 AM
 Subject: Re: [Pcsclite-muscle] question about locking and reconnect
   
Hi again,
In my little understanding the idea behind SCardReconnect is that it is just a 
SCardDisconnect + SCardConnect. And, because SCardDisconnect releases any lock, 
SCardReconnect should also do the same. If you want to lock you need to start 
the transaction again just like after a normal SCardConnect (in shared mode of 
course).
Regards!
   
--- reader-pcsc.c.ORIG	2015-05-27 22:40:07.867598965 +0200
+++ reader-pcsc.c	2015-06-02 18:11:46.938925901 +0200
@@ -425,8 +425,10 @@
 	if (check_forced_protocol(reader->ctx, &reader->atr, &tmp))
 		protocol = tmp;
 
-	/* reconnect always unlocks transaction */
+#ifdef _WIN32
+	/* reconnect unlocks transaction in windows but not in pcsc-lite */
 	priv->locked = 0;
+#endif
 
 	rv = priv->gpriv->SCardReconnect(priv->pcsc_card,
 			    priv->gpriv->connect_exclusive ? SCARD_SHARE_EXCLUSIVE : SCARD_SHARE_SHARED,
@@ -575,17 +577,21 @@
 
 static int pcsc_reset(sc_reader_t *reader, int do_cold_reset)
 {
+#ifdef _WIN32
 	struct pcsc_private_data *priv = GET_PRIV_DATA(reader);
-	int r;
 	int old_locked = priv->locked;
+#endif
+	int r;
 
 	r = pcsc_reconnect(reader, do_cold_reset ? SCARD_UNPOWER_CARD : SCARD_RESET_CARD);
 	if(r != SC_SUCCESS)
 		return r;
 
-	/* pcsc_reconnect unlocks card... try to lock it again if it was locked */
+#ifdef _WIN32
+	/* pcsc_reconnect unlocks card in windows... try to lock it again if it was locked */
 	if(old_locked)
 		r = pcsc_lock(reader);
+#endif
 
 	return r;
 }
_______________________________________________
Pcsclite-muscle mailing list
[email protected]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pcsclite-muscle

Reply via email to