Logo Search packages:      
Sourcecode: pcsc-lite version File versions  Download package

LONG IFDCloseIFD ( READER_CONTEXT *  rContext  ) 

Close a communication channel to the IFD.

Definition at line 188 of file ifdwrapper.c.

References IFD_SUCCESS, IFDHCloseChannel(), and SYS_USleep().

{
      RESPONSECODE rv = IFD_SUCCESS;
      int repeat;

#ifndef PCSCLITE_STATIC_DRIVER
      RESPONSECODE(*IO_close_channel) (void) = NULL;
      RESPONSECODE(*IFDH_close_channel) (DWORD) = NULL;

      if (rContext->version == IFD_HVERSION_1_0)
            IO_close_channel = rContext->psFunctions.psFunctions_v1.pvfCloseChannel;
      else
            IFDH_close_channel = rContext->psFunctions.psFunctions_v2.pvfCloseChannel;
#endif

      /* TRY TO LOCK THIS CODE REGION */
      repeat = 5;
again:
      rv = pthread_mutex_trylock(rContext->mMutex);
      if (EBUSY == rv)
      {
            Log1(PCSC_LOG_ERROR, "Locking failed");
            repeat--;
            if (repeat)
            {
                  (void)SYS_USleep(100*1000);   /* 100 ms */
                  goto again;
            }
      }

#ifndef PCSCLITE_STATIC_DRIVER
      if (rContext->version == IFD_HVERSION_1_0)

            rv = (*IO_close_channel) ();
      else
            rv = (*IFDH_close_channel) (rContext->slot);
#else
#ifdef IFDHANDLERv1
      rv = IO_Close_Channel();
#else
      rv = IFDHCloseChannel(rContext->slot);
#endif
#endif

      /* END OF LOCKED REGION */
      (void)pthread_mutex_unlock(rContext->mMutex);

      return rv;
}


Generated by  Doxygen 1.6.0   Back to index