Ejemplo n.º 1
0
    bool init(RcfConfigT *)
    {
        Lock lock(getRootMutex());
        if (gInitRefCount == 0)
        {

            gpGlobals = new Globals();

            // General initialization.
            
            RCF::getCurrentTimeMs();
            initAmiHandlerCache();
            initLogManager();
            initAmi();
            initObjectPool();
            initPerformanceData();
            initThreadLocalData();
            initTpHandlerCache();


#if RCF_FEATURE_FILETRANSFER==1
            initFileIoThreadPool();
#endif


#if RCF_FEATURE_SF==1
            initRegistrySingleton();
#endif


#ifdef BOOST_WINDOWS
            initWinsock();
            initPfnGetUserName();
#endif


#ifndef BOOST_WINDOWS
            // Disable broken pipe signals on non-Windows platforms.
            std::signal(SIGPIPE, SIG_IGN);
#endif


#if RCF_FEATURE_SSPI==1
            SspiInitialize();
#endif

           
#if RCF_FEATURE_SERVER==1
            // Start the AMI thread pool.
            gpAmiThreadPool = new AmiThreadPool(); 
            gpAmiThreadPool->start();
#endif

        }

        ++gInitRefCount;
        return gInitRefCount == 1;
    }
Ejemplo n.º 2
0
Server::Server () : connectionsPool (100),
                    connectionsScheduler (this),
                    listenThreads (&connectionsScheduler, this),
                    authMethodFactory (&cryptAlgoManager),
                    validatorFactory (),
                    securityManager (&validatorFactory, &authMethodFactory)
{
  toReboot = false;
  autoRebootEnabled = true;
  rebooting = false;
  maxConnections = 0;
  serverReady = false;
  throttlingRate = 0;
  path = 0;
  vhostHandler = NULL;
  purgeThreadsThreshold = 1;
  freeThreads = 0;
  logManager = new LogManager (&filtersFactory);
  xmlValidator = new XmlValidator ();
  initLogManager ();
  connectionsPoolLock.init ();
  configurationFileManager = NULL;
  genMainConf = NULL;
}
Ejemplo n.º 3
0
    bool init(RcfConfigT *)
    {
        Lock lock(getRootMutex());
        if (gInitRefCount == 0)
        {

            gpGlobals = new Globals();

            // General initialization.

            RCF::getCurrentTimeMs();
            initAmiHandlerCache();
            IdentityFilter::spFilterDescription = new FilterDescription("identity filter", RcfFilter_Identity, true);
            XorFilter::spFilterDescription = new FilterDescription("Xor filter", RcfFilter_Xor, true);
            initFileIoThreadPool();
            initAmi();
            
            #if defined(BOOST_WINDOWS)
            initNamedPipeEndpointSerialization();
            #endif

            initObjectPool();
            initPerformanceData();
            

            //#if defined(sun) || defined(__sun) || defined(__sun__)
            //if (!pThreadLocalDataPtr) pThreadLocalDataPtr = new ThreadLocalDataPtr;
            //#endif

            initThreadLocalData();
            initTpHandlerCache();

            #ifdef RCF_USE_OPENSSL
            //initOpenSsl();
            initOpenSslEncryptionFilterDescription();
            #endif

            #ifdef RCF_USE_ZLIB
            initZlibCompressionFilterDescriptions();
            #endif

            initLogManager();

            #ifdef RCF_USE_SF_SERIALIZATION
            initRegistrySingleton();
            initTcpEndpointSerialization();
            initUdpEndpointSerialization();
            
            #if defined(BOOST_WINDOWS)
            initWin32NamedPipeEndpointSerialization();            
            #endif

            #ifdef RCF_HAS_LOCAL_SOCKETS
            initUnixLocalEndpointSerialization();
            #endif

            #endif // RCF_USE_SF_SERIALIZATION


            #ifdef BOOST_WINDOWS
            initWinsock();
            initPfnGetUserName();
            SspiInitialize();
            #endif

#ifndef BOOST_WINDOWS
            // Disable broken pipe signals.
            std::signal(SIGPIPE, SIG_IGN);
#endif
            
            // Start the AMI thread pool.
            gpAmiThreadPool = new AmiThreadPool(); 
            gpAmiThreadPool->start();
        }

        ++gInitRefCount;
        return gInitRefCount == 1;
    }
Ejemplo n.º 4
0
/*!
  Here is loaded the configuration of the server.
  The configuration file is a XML file.
  Return nonzero on errors.
 */
int Server::initialize ()
{
  const char *data;
#ifdef WIN32
  envString = GetEnvironmentStrings ();
#endif
  connectionsMutex = new Mutex ();
  threadsMutex = new Mutex ();

  /* Store the default values.  */
  nStaticThreads = 20;
  nMaxThreads = 50;
  currentThreadID = 0;
  freeThreads = 0;
  connectionTimeout = MYSERVER_SEC (180);
  endServer = false;
  purgeThreadsThreshold = 1;
  throttlingRate = 0;
  maxConnections = 0;
  maxConnectionsToAccept = 0;

  if (genMainConf)
    {
      configurationFileManager = genMainConf (this,
                                              mainConfigurationFile.c_str ());
      if (!configurationFileManager)
        {
          log (MYSERVER_LOG_MSG_ERROR,
               _("Error while loading the %s configuration file"),
               mainConfigurationFile.c_str ());
          return -1;
        }

    }
  else
    {
      XmlMainConfiguration *xmlMainConf = new XmlMainConfiguration ();
      if (xmlMainConf->open (mainConfigurationFile.c_str ()))
        {
          log (MYSERVER_LOG_MSG_ERROR,
               _("Error while loading the %s configuration file"),
               mainConfigurationFile.c_str ());
          delete xmlMainConf;
          return -1;
        }
      configurationFileManager = xmlMainConf;
    }

  configurationFileManager->readData (&hashedDataTrees, &hashedData);

  /* Process console colors information.  */
  list<string> levels = logManager->getLoggingLevelsByNames ();
  for (list<string>::iterator it = levels.begin (); it != levels.end (); it++)
    {
      string fg (*it + "_fg");
      string bg (*it + "_bg");

      string fullFg ("log_color." + *it + "_fg");
      string fullBg ("log_color." + *it + "_bg");
      data = getData (fullFg.c_str ());
      if (data)
        consoleColors[fg] = string (data);

      data = getData (fullBg.c_str ());
      if (data)
        consoleColors[bg] = string (data);
    }

  initLogManager ();

  data = getData ("server.buffer_size", "102400");
  if (data)
    buffersize = (atol (data) > 81920) ?  atol (data) :  81920 ;

  data = getData ("connection.timeout");
  if (data)
    connectionTimeout = MYSERVER_SEC ((u_long) atol (data));

  data = getData ("server.static_threads");
  if (data)
    nStaticThreads = atoi (data);

  data = getData ("server.max_threads");
  if (data)
    nMaxThreads = atoi (data);

  /* Get the max connections number to allow.  */
  data = getData ("server.max_connections");
  if (data)
    maxConnections = atoi (data);

  /* Get the max connections number to accept.  */
  data = getData ("server.max_accepted_connections");
  if (data)
    maxConnectionsToAccept = atoi (data);

  data = getData ("server.connections_pool.size");
  if (data)
    connectionsPool.init (atoi (data));

  /* Get the default throttling rate to use on connections.  */
  data = getData ("connection.throttling");
  if (data)
    throttlingRate = (u_long) atoi (data);

  data = getData ("server.max_log_size");
  if (data)
    maxLogFileSize=(u_long) atol (data);

  data = getData ("server.max_files_cache");
  if (data)
    {
      u_long maxSize = (u_long) atol (data);
      cachedFiles.initialize (maxSize);
    }
  else
    cachedFiles.initialize (1 << 23);

  data = getData ("server.temp_directory");
  if (data)
    {
      string tmpPath (data);
      FilesUtility::completePath (tmpPath);
      FilesUtility::setTmpPath (tmpPath);
    }
  else
    FilesUtility::resetTmpPath ();

  data = getData ("server.max_file_cache");
  if (data)
    {
      u_long maxSize = (u_long) atol (data);
      cachedFiles.setMaxSize (maxSize);
    }

  data = getData ("server.min_file_cache");
  if (data)
    {
      u_long minSize = (u_long) atol (data);
      cachedFiles.setMinSize (minSize);
    }

  data = getData ("server.uid");
  if (data)
    uid.assign (data);
  else
    uid.assign ("");

  data = getData ("server.gid");
  if (data)
    gid.assign (data);
  else
    gid.assign ("");

  data = getData ("server.max_servers");
  if (data)
    {
      int maxServersProcesses = atoi (data);
      getProcessServerManager ()->setMaxServers (maxServersProcesses);
    }

  return 0;
}