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

void SVCServiceRunLoop ( void   ) 

The Server's Message Queue Listener function.

An endless loop calls the function SHMProcessEventsServer() to check for messages sent by clients. If the message is valid, CreateContextThread() is called to serve this request.

Definition at line 88 of file pcscdaemon.c.

References CreateContextThread(), SHMInitializeCommonSegment(), SHMProcessEventsServer(), SYS_MutexInit(), and SYS_Sleep().

{
      int rsp;
      LONG rv;
      DWORD dwClientID; /* Connection ID used to reference the Client */
      
      rsp = 0;
      rv = 0;

      /*
       * Initialize the comm structure 
       */
      rsp = SHMInitializeCommonSegment();

      if (rsp == -1)
      {
            Log1(PCSC_LOG_CRITICAL, "Error initializing pcscd.");
            exit(-1);
      }

      /*
       * Initialize the contexts structure 
       */
      rv = ContextsInitialize();

      if (rv == -1)
      {
            Log1(PCSC_LOG_CRITICAL, "Error initializing pcscd.");
            exit(-1);
      }

      /*
       * Solaris sends a SIGALRM and it is annoying 
       */

      signal(SIGALRM, SIG_IGN);
      signal(SIGPIPE, SIG_IGN);
      signal(SIGHUP, SIG_IGN);      /* needed for Solaris. The signal is sent
                         * when the shell is existed */

      /*
       * This function always returns zero 
       */
      rsp = SYS_MutexInit(&usbNotifierMutex);

      /*
       * Set up the search for USB/PCMCIA devices 
       */
      HPSearchHotPluggables();
      HPRegisterForHotplugEvents();

      /*
       * Set up the power management callback routine
       */
      PMRegisterForPowerEvents();

      while (TRUE)
      {

            switch (rsp = SHMProcessEventsServer(&dwClientID, 0))
            {

            case 0:
                  Log2(PCSC_LOG_DEBUG, "A new context thread creation is requested: %d", dwClientID);
                  rv = CreateContextThread(&dwClientID);

                  if (rv != SCARD_S_SUCCESS)
                  {
                        Log1(PCSC_LOG_ERROR, "Problem during the context thread creation");
                        AraKiri = TRUE;
                  }

                  break;

            case 2:
                  /*
                   * timeout in SHMProcessEventsServer(): do nothing
                   * this is used to catch the Ctrl-C signal at some time when
                   * nothing else happens
                   */
                  break;

            case -1:
                  /* do not display if we are exiting or re-reading the config */
                  if ((!AraKiri) && (!ReCheckSerialReaders))
                        Log1(PCSC_LOG_ERROR, "Error in SHMProcessEventsServer");
                  break;

            default:
                  Log2(PCSC_LOG_ERROR, "SHMProcessEventsServer unknown retval: %d",
                        rsp);
                  break;
            }

            if (AraKiri)
            {
                  /* stop the hotpug thread and waits its exit */
                  HPStopHotPluggables();
                  SYS_Sleep(1);

                  /* now stop all the drivers */
                  RFCleanupReaders(1);
            }
      }
}


Generated by  Doxygen 1.6.0   Back to index