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

void SCardUnload ( void   ) 

free resources allocated by the library You _shall_ call this function if you use dlopen/dlclose to load/unload the library. Otherwise you will exhaust the ressources available.

Definition at line 1896 of file winscard_scf.c.

References isExecuted, mapAddr, SHMClientCloseSession(), and SYS_CloseFile().

{
    int i=0;
#if 0
      if (!isExecuted)
            return;

      SHMClientCloseSession();
      SYS_CloseFile(mapAddr);
      isExecuted = 0;
#endif

    /*
       *    Cleanup only if PCSC has been initialized and there are no active
       *    context.  Checking for active context is critical when libpcsclite is
       *    linked with multiple modules. for eg. an application links with
       *    pcsclite and a PAM module also links with pcsclite, when the PAM is
       *    unloaded from memory and if it calls SCardUnload, pcsclite will
       *    un-initialize even though there are active references from the
       *    application. Now, why dont we add SCardUnload to the array of functions
       *    to be called on unload (-zfiniarray=SCUnload), well, that does not seem
       *    to solve the problem, SCardUnload is called when PAM is unloaded from
       *    memory having the same impact that PCSC is uninitialized enen though
       *    there are active references.
     */
      if((!PCSC_Initialized) || isActiveContextPresent()) 
            return;

      for(i=0; i<PCSCLITE_MAX_READERS_CONTEXTS; i++) 
            if (psReaderMap[i].hTerminal)
            {
                  SCF_Terminal_removeEventListener(psReaderMap[i].hTerminal,
                        psReaderMap[i].lHandle);

                  SCF_Terminal_close(psReaderMap[i].hTerminal); 

                  if (psReaderMap[i].ReaderName)
                        free(psReaderMap[i].ReaderName);
            }   

      SCF_Session_close(g_hSession);
      PCSC_Initialized = 0;
}


Generated by  Doxygen 1.6.0   Back to index