Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

Server Class Reference

Inheritance diagram for Server:

MulticastRegistry< string, void *, int > List of all members.

Public Member Functions

int addConnection (Socket, MYSERVER_SOCKADDRIN *)
void checkThreadsNumber ()
int countAvailableThreads ()
void decreaseFreeThread ()
int deleteConnection (ConnectionPtr, int, int=1)
void disableAutoReboot ()
void enableAutoReboot ()
void finalCleanup ()
const char * getAddresses ()
u_long getBuffersize ()
u_long getBuffersize2 ()
CachedFileFactorygetCachedFiles ()
XmlParsergetConfiguration ()
ConnectionPtr getConnection (int)
void getConnections (list< ConnectionPtr > &)
ConnectionsSchedulergetConnectionsScheduler ()
const char * getDefaultFilenamePath (u_long ID=0)
void * getEnvString ()
const char * getExternalPath ()
FiltersFactorygetFiltersFactory ()
u_long getGid ()
void * getGlobalData (const char *name)
const char * getHashedData (const char *name)
HomeDirgetHomeDir ()
const char * getLanguageFile ()
XmlParsergetLanguageParser ()
const char * getLanguagesPath ()
ListenThreadsgetListenThreads ()
const char * getMainConfFile ()
int getMaxLogFileSize ()
int getMaxThreads ()
const char * getMIMEConfFile ()
MimeManagergetMimeManager ()
u_long getNumConnections ()
u_long getNumThreads ()
u_long getNumTotalConnections ()
const char * getPath ()
PluginsManagergetPluginsManager ()
ProcessServerManagergetProcessServerManager ()
ProtocolgetProtocol (const char *protocolName)
ProtocolsManagergetProtocolsManager ()
const char * getServerAdmin ()
const char * getServerName ()
u_long getThrottlingRate ()
u_long getTimeout ()
u_long getUid ()
u_long getVerbosity ()
const char * getVhostConfFile ()
VhostManagergetVhosts ()
void increaseFreeThread ()
int isAutorebootEnabled ()
int isRebooting ()
int isServerReady ()
int logEndPrintError ()
int logLockAccess ()
int logPreparePrintError ()
int logUnlockAccess ()
int logWriteln (string const &str)
int logWriteln (const char *)
int mustUseLogonOption ()
void rebootOnNextLoop ()
int removeThread (u_long ID)
void setGlobalData (const char *name, void *data)
int setLogFile (char *)
void setProcessPermissions ()
void setVerbosity (u_long)
void start ()
void stop ()
bool stopServer ()
void temporaryFileName (u_long tid, string &out)
int terminate ()
int waitNewConnection (u_long tid, u_long timeout)
 ~Server ()

Static Public Member Functions

void createInstance ()
ServergetInstance ()

Private Member Functions

ConnectionPtr addConnectionToList (Socket *s, MYSERVER_SOCKADDRIN *asock_in, char *ipAddr, char *localIpAddr, u_short port, u_short localPort, int)
int addThread (int staticThread=0)
void clearAllConnections ()
int freeHashedData ()
int initialize (int)
int loadSettings ()
int purgeThreads ()
int reboot ()
 Server ()

Private Attributes

int autoRebootEnabled
u_long buffersize
u_long buffersize2
CachedFileFactory cachedFiles
XmlParser configurationFileManager
MutexconnectionsMutex
ConnectionsScheduler connectionsScheduler
u_long connectionTimeout
int currentThreadID
void * envString
DynExecutorManager executors
string * externalPath
DynamicFiltersManager filters
FiltersFactory filtersFactory
u_long freeThreads
GenericPluginsManager genericPluginsManager
u_long gid
HashMap< string, void * > globalData
HashMap< string, string * > hashedData
HomeDir homeDir
string * ipAddresses
string * languageFile
XmlParser languageParser
string * languagesPath
ListenThreads listenThreads
LogManager logManager
string * mainConfigurationFile
u_long maxConnections
u_long maxConnectionsToAccept
u_long maxLogFileSize
string * mimeConfigurationFile
MimeManagermimeManager
int mustEndServer
u_long nMaxThreads
u_long nStaticThreads
u_long nTotalConnections
string * path
int pausing
PluginsManager pluginsManager
ProcessServerManager processServerManager
ProtocolsManager protocols
u_long purgeThreadsThreshold
int rebooting
string * serverAdmin
char serverName [HOST_NAME_MAX+1]
int serverReady
list< ClientsThread * > threads
MutexthreadsMutex
u_long throttlingRate
string tmpPath
int toReboot
u_long uid
u_long verbosity
string * vhostConfigurationFile
VhostManagervhostList

Static Private Attributes

Serverinstance = 0

Friends

class ClientsThread
int control_handler (u_long control_type)

Constructor & Destructor Documentation

Server::~Server  ) 
 

Destroy the object.

Server::Server  )  [private]
 

Do not allow to create directly objects.


Member Function Documentation

int Server::addConnection Socket  s,
MYSERVER_SOCKADDRIN asockIn
 

This function add a new connection to the list.

ConnectionPtr Server::addConnectionToList Socket s,
MYSERVER_SOCKADDRIN asock_in,
char *  ipAddr,
char *  localIpAddr,
u_short  port,
u_short  localPort,
int 
[private]
 

Add a new connection. A connection is defined using a connection struct.

int Server::addThread int  staticThread = 0  )  [private]
 

Create a new thread.

void Server::checkThreadsNumber  ) 
 

Check if there are free threads to handle a new request. If there are not enough threads create a new one.

void Server::clearAllConnections  )  [private]
 

Delete all the active connections.

int Server::countAvailableThreads  ) 
 

Check how many threads are not working.

void Server::createInstance  )  [static]
 

Create the class instance. Call this before use the Server class. The instance is not created in getInstance to have a faster inline function.

void Server::decreaseFreeThread  ) 
 

Remove a free thread.

int Server::deleteConnection ConnectionPtr  s,
int  ,
int  doLock = 1
 

Delete a connection from the list.

void Server::disableAutoReboot  ) 
 

Disable the autoreboot.

void Server::enableAutoReboot  ) 
 

Enable the autoreboot

void Server::finalCleanup  ) 
 

Do the final cleanup. Called once when the process is terminated.

int Server::freeHashedData  )  [private]
 

Clear the data dictionary. Returns zero on success.

const char * Server::getAddresses  ) 
 

Returns a comma-separated local machine IPs list. For example: 192.168.0.1, 61.62.63.64, 65.66.67.68.69

u_long Server::getBuffersize  ) 
 

Get the size for the first buffer.

u_long Server::getBuffersize2  ) 
 

Get the size for the second buffer.

CachedFileFactory * Server::getCachedFiles  ) 
 

Return the factory object to create cached files.

XmlParser* Server::getConfiguration  ) 
 

ConnectionPtr Server::getConnection int   ) 
 

Get a connection to parse.

void Server::getConnections list< ConnectionPtr > &  out  ) 
 

Get a list with all the alive connections.

ConnectionsScheduler* Server::getConnectionsScheduler  ) 
 

const char* Server::getDefaultFilenamePath u_long  ID = 0  ) 
 

void* Server::getEnvString  ) 
 

const char * Server::getExternalPath  ) 
 

Get where external protocols are.

FiltersFactory * Server::getFiltersFactory  ) 
 

Get a pointer to a filters factory object.

u_long Server::getGid  ) 
 

Return the group identifier to use for the process.

void * Server::getGlobalData const char *  name  ) 
 

Get a global descriptor.

const char * Server::getHashedData const char *  name  ) 
 

Get the value for name in the hash dictionary.

HomeDir * Server::getHomeDir  ) 
 

Return a home directory object.

Server* Server::getInstance  )  [static]
 

const char * Server::getLanguageFile  ) 
 

Get the current language file.

XmlParser * Server::getLanguageParser  ) 
 

Get a pointer to the language parser.

const char * Server::getLanguagesPath  ) 
 

Get the path to the directory containing all the language files.

ListenThreads* Server::getListenThreads  ) 
 

const char * Server::getMainConfFile  ) 
 

Return the path to the mail configuration file.

int Server::getMaxLogFileSize  ) 
 

This function returns the max size of the logs file as defined in the configuration file.

int Server::getMaxThreads  ) 
 

Return the max number of threads that the server can start.

const char * Server::getMIMEConfFile  ) 
 

Return the path to the mail configuration file.

MimeManager* Server::getMimeManager  ) 
 

u_long Server::getNumConnections  ) 
 

Returns the numbers of active connections the list.

u_long Server::getNumThreads  ) 
 

Gets the number of threads.

u_long Server::getNumTotalConnections  ) 
 

Returns the numbers of all the connections to the server.

const char * Server::getPath  ) 
 

Returns the full path of the binaries directory. The directory where the file myserver(.exe) is.

PluginsManager* Server::getPluginsManager  ) 
 

ProcessServerManager* Server::getProcessServerManager  ) 
 

Protocol * Server::getProtocol const char *  protocolName  ) 
 

Get the specified protocol.

ProtocolsManager * Server::getProtocolsManager  ) 
 

Return the ProtocolManager object.

const char * Server::getServerAdmin  ) 
 

Get the server administrator e-mail address. To change this use the main configuration file.

const char * Server::getServerName  ) 
 

Returns the name of the server(the name of the current PC).

u_long Server::getThrottlingRate  ) 
 

Get the default throttling rate to use with connections to the server.

u_long Server::getTimeout  ) 
 

Returns the connection timeout.

u_long Server::getUid  ) 
 

Return the user identifier to use for the process.

u_long Server::getVerbosity  ) 
 

Get the verbosity value.

const char * Server::getVhostConfFile  ) 
 

Return the path to the mail configuration file.

VhostManager* Server::getVhosts  ) 
 

void Server::increaseFreeThread  ) 
 

Add a free thread.

int Server::initialize int   )  [private]
 

Here is loaded the configuration of the server. The configuration file is a XML file. Return nonzero on errors.

int Server::isAutorebootEnabled  ) 
 

Return nonzero if the autoreboot is enabled.

int Server::isRebooting  ) 
 

int Server::isServerReady  ) 
 

Returns if the server is ready.

int Server::loadSettings  )  [private]
 

Load the main server settings. Return nonzero on errors.

int Server::logEndPrintError  ) 
 

Exit from the error printing mode.

int Server::logLockAccess  ) 
 

Lock the access to the log file.

int Server::logPreparePrintError  ) 
 

Prepare the log to print an error.

int Server::logUnlockAccess  ) 
 

Unlock the access to the log file.

int Server::logWriteln string const &  str  ) 
 

int Server::logWriteln const char *  str  ) 
 

Write a string to the log file and terminate the line.

int Server::mustUseLogonOption  ) 
 

int Server::purgeThreads  )  [private]
 

Removed threads that can be destroyed. The function returns the number of threads that were destroyed.

int Server::reboot  )  [private]
 

Reboot the server. Returns non zero on errors.

void Server::rebootOnNextLoop  ) 
 

Reboot the server on the next loop.

int Server::removeThread u_long  ID  ) 
 

Remove a thread. Return zero if a thread was removed.

void Server::setGlobalData const char *  name,
void *  data
 

Set a global descriptor.

int Server::setLogFile char *  fileName  ) 
 

Use a specified file as log.

void Server::setProcessPermissions  ) 
 

If specified set the uid/gid for the process.

void Server::setVerbosity u_long  nv  ) 
 

Set the verbosity value.

void Server::start  ) 
 

Start the server.

void Server::stop  ) 
 

Stop the execution of the server.

bool Server::stopServer  ) 
 

void Server::temporaryFileName u_long  tid,
string &  out
 

Create an unique temporary file name. This function doesn't create the file or open it but generates only its name.

Parameters:
 

int Server::terminate  ) 
 

Unload the server. Return nonzero on errors.

int Server::waitNewConnection u_long  tid,
u_long  timeout
 


Friends And Related Function Documentation

friend class ClientsThread [friend]
 

int control_handler u_long  control_type  )  [friend]
 


Member Data Documentation

int Server::autoRebootEnabled [private]
 

u_long Server::buffersize [private]
 

u_long Server::buffersize2 [private]
 

CachedFileFactory Server::cachedFiles [private]
 

XmlParser Server::configurationFileManager [private]
 

Mutex* Server::connectionsMutex [private]
 

ConnectionsScheduler Server::connectionsScheduler [private]
 

u_long Server::connectionTimeout [private]
 

int Server::currentThreadID [private]
 

void* Server::envString [private]
 

DynExecutorManager Server::executors [private]
 

string* Server::externalPath [private]
 

DynamicFiltersManager Server::filters [private]
 

FiltersFactory Server::filtersFactory [private]
 

u_long Server::freeThreads [private]
 

GenericPluginsManager Server::genericPluginsManager [private]
 

u_long Server::gid [private]
 

HashMap<string, void*> Server::globalData [private]
 

HashMap<string, string*> Server::hashedData [private]
 

HomeDir Server::homeDir [private]
 

Server * Server::instance = 0 [static, private]
 

Singleton instance. Call createInstance before use it.

string* Server::ipAddresses [private]
 

Buffer that contains all the local machine IP values.

string* Server::languageFile [private]
 

XmlParser Server::languageParser [private]
 

string* Server::languagesPath [private]
 

ListenThreads Server::listenThreads [private]
 

LogManager Server::logManager [private]
 

string* Server::mainConfigurationFile [private]
 

u_long Server::maxConnections [private]
 

u_long Server::maxConnectionsToAccept [private]
 

u_long Server::maxLogFileSize [private]
 

string* Server::mimeConfigurationFile [private]
 

MimeManager* Server::mimeManager [private]
 

int Server::mustEndServer [private]
 

When the flag mustEndServer is 1 all the threads are stopped and the application stop its execution.

u_long Server::nMaxThreads [private]
 

u_long Server::nStaticThreads [private]
 

u_long Server::nTotalConnections [private]
 

string* Server::path [private]
 

int Server::pausing [private]
 

Used when rebooting to load new configuration files.

PluginsManager Server::pluginsManager [private]
 

ProcessServerManager Server::processServerManager [private]
 

ProtocolsManager Server::protocols [private]
 

u_long Server::purgeThreadsThreshold [private]
 

int Server::rebooting [private]