This is a static class to control the load of requests on the server. More...
#include <DcLoadController.h>
Static Public Member Functions | |
static void | Init () |
Load the parameters from parameters file. | |
static bool | AddThread (CdcSocket *psock) |
This function checks if it can add new thread to the open threads of the server. | |
static void | ThreadDone (CdcSocket *psock) |
This function decreases one from the total number of open threads and from open threads for this client. |
This is a static class to control the load of requests on the server.
It controls two parameters: The number of open threads, and the number of open threads per one client (IP address). If the global limit is reached, the main thread will sleep for some time. This will let the rest of the (lower priority) threads a chance to finish their job under DoS attack. If one of the limits reached, the class send 503 error message to the client and delete the socket. Parameters are in the server configuration file under: Total-Threads-Limit, Client-Threads-Limit and Overload-Sleep.
Definition at line 43 of file DcLoadController.h.
bool CdcLoadController::AddThread | ( | CdcSocket * | psock ) | [static] |
This function checks if it can add new thread to the open threads of the server.
It gets a pointer to CdcSocket object. If the number of opened threads is lower then the limit and the numbers of thread for this client is lower then the limit, it increase both values and return True. If one of the values is at the limit, it sends code 503 to the client and returns False.
Definition at line 48 of file DcLoadController.cpp.
void CdcLoadController::Init | ( | ) | [static] |
Load the parameters from parameters file.
Definition at line 32 of file DcLoadController.cpp.
void CdcLoadController::ThreadDone | ( | CdcSocket * | psock ) | [static] |
This function decreases one from the total number of open threads and from open threads for this client.
if the total number of open threads is zero (we have some time), it clears the clients map.
Definition at line 87 of file DcLoadController.cpp.