On Mon, Apr 21, 2008 at 11:20 AM, Ludovic Rousseau
<[EMAIL PROTECTED]> wrote:
>  On Sun, Apr 20, 2008 at 11:23 PM,  <[EMAIL PROTECTED]> wrote:
>  > Revision: 3483
>  >  Author:   alonbl
>  >  Date:     2008-04-20 23:23:26 +0200 (Sun, 20 Apr 2008)
>  >
>  >  Log Message:
>  >  -----------
>  >  Handle SCARD_E_INVALID_HANDLE at pcsc_lock
>  >
>  >  Modified Paths:
>  >  --------------
>  >     branches/alonbl/pnp/src/libopensc/internal-winscard.h
>  >     branches/alonbl/pnp/src/libopensc/reader-pcsc.c
>  >  Modified: branches/alonbl/pnp/src/libopensc/internal-winscard.h
>  >  ===================================================================
>  >  --- branches/alonbl/pnp/src/libopensc/internal-winscard.h       
> 2008-04-20 17:30:54 UTC (rev 3482)
>  >  +++ branches/alonbl/pnp/src/libopensc/internal-winscard.h       
> 2008-04-20 21:23:26 UTC (rev 3483)
>  >  @@ -51,6 +51,7 @@
>  >   #define SCARD_SCOPE_USER               0x0000  /**< Scope in user space 
> */
>  >
>  >   #define SCARD_S_SUCCESS                        0x00000000 /**< No error 
> was encountered. */
>  >  +#define SCARD_E_INVALID_HANDLE         0x80100003 /**< The supplied 
> handle was invalid. */
>  >   #define SCARD_E_TIMEOUT                        0x8010000A /**< The 
> user-specified timeout value has expired. */
>  >   #define SCARD_E_SHARING_VIOLATION      0x8010000B /**< The smart card 
> cannot be accessed because of other connections outstanding. */
>  >   #define SCARD_E_NOT_TRANSACTED         0x80100016 /**< An attempt was 
> made to end a non-existent transaction. */
>  >
>  >  Modified: branches/alonbl/pnp/src/libopensc/reader-pcsc.c
>  >  ===================================================================
>  >  --- branches/alonbl/pnp/src/libopensc/reader-pcsc.c     2008-04-20 
> 17:30:54 UTC (rev 3482)
>  >  +++ branches/alonbl/pnp/src/libopensc/reader-pcsc.c     2008-04-20 
> 21:23:26 UTC (rev 3483)
>  >  @@ -644,6 +644,21 @@
>  >
>  >         rv = priv->gpriv->SCardBeginTransaction(pslot->pcsc_card);
>  >
>  >  +       if ((unsigned int)rv == SCARD_E_INVALID_HANDLE) {
>  >  +               rv = pcsc_connect(reader, slot);
>  >  +               if (rv != SCARD_S_SUCCESS) {
>  >  +                       PCSC_ERROR(reader->ctx, "SCardConnect failed", 
> rv);
>  >  +                       return pcsc_ret_to_error(rv);
>  >  +               }
>  >  +/* STRANGE-BEGIN */
>  >  +rv = priv->gpriv->SCardEndTransaction(pslot->pcsc_card, 
> SCARD_RESET_CARD);
>  >  +               /* Now try to begin a new transaction after we 
> reconnected and we fail if
>  >  +                some other program was faster to lock the reader */
>  >  +/*             rv = priv->gpriv->SCardBeginTransaction(pslot->pcsc_card);
>  >  + */
>  >  +/* STRANGE-END */
>  >  +       }
>  >  +
>  >         if ((unsigned int)rv == SCARD_W_RESET_CARD) {
>  >                 /* try to reconnect if the card was reset by some other 
> application */
>  >                 rv = pcsc_reconnect(reader, slot, 0);
>
>  Why is the SCardEndTransaction() call needed?
>  It is needed to Linux or Windows or both?
>
>  If the application calls SCardConnect() again then all previous
>  transactions should be automatically ended. If not I think it is a bug
>  in the PC/SC layer.

I just saw the next patch about "The STRANGE was due to pcscd fork() issue".
No need to answer my previous questions.

Bye

-- 
 Dr. Ludovic Rousseau
_______________________________________________
opensc-devel mailing list
[email protected]
http://www.opensc-project.org/mailman/listinfo/opensc-devel

Reply via email to