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

LONG CreateContextThread ( PDWORD  pdwClientID  ) 

Creates threads to handle messages received from Clients.

Parameters:
[in] pdwClientID Connection ID used to reference the Client.
Returns:
Error code.
Return values:
SCARD_S_SUCCESS Success.
SCARD_F_INTERNAL_ERROR Exceded the maximum number of simultaneous Application Contexts.
SCARD_E_NO_MEMORY Error creating the Context Thread.

Definition at line 81 of file winscard_svc.c.

References ContextThread(), _psContext::dwClientID, dwNextContextIndex, psContext, SYS_CloseFile(), and SYS_ThreadCreate().

Referenced by SVCServiceRunLoop().

{
      int i;

      for (i = 0; i < PCSCLITE_MAX_APPLICATIONS_CONTEXTS; i++)
      {
            if (psContext[i].dwClientID == 0)
            {
                  psContext[i].dwClientID = *pdwClientID;
                  *pdwClientID = 0;
                  break;
            }
      }

      if (i == PCSCLITE_MAX_APPLICATIONS_CONTEXTS)
      {
            SYS_CloseFile(psContext[i].dwClientID);
            psContext[i].dwClientID = 0; 
            return SCARD_F_INTERNAL_ERROR;
      }
      
      dwNextContextIndex = i;

      if (SYS_ThreadCreate(&psContext[i].pthThread, THREAD_ATTR_DETACHED,
            (PCSCLITE_THREAD_FUNCTION( )) ContextThread,
            (LPVOID) &dwNextContextIndex) != 1)
      {
            SYS_CloseFile(psContext[i].dwClientID);
            psContext[i].dwClientID = 0; 
            return SCARD_E_NO_MEMORY;
      }

      return SCARD_S_SUCCESS;
}


Generated by  Doxygen 1.6.0   Back to index