General task and protocol management class. More...
|Queue type for pending tasks. More...|
|ManagerPar (int fd, const boost::function< void(Protocol::FullId, Message)> &sendMessage_, bool doSetupSignals)|
|Construct from a file descriptor. |
|Halter for the handler() function. |
|Terminator for the handler() function. |
|Configure the handlers for POSIX signals. |
|size_t||getMessagesSize () const|
|Tells you the size of the message queue. |
|void||localHandler (Protocol::FullId id)|
|Handles management messages. |
|Handles low level communication with the other side. |
|Queue for pending tasks. |
|std::queue< Message >||messages|
|A queue of messages for the manager itself. |
|Indicated whether or not the manager is currently in sleep mode. |
|Mutex to make accessing asleep thread safe. |
|The pthread id of the thread the handler() function is operating in. |
|Boolean value indicating that handler() should halt. |
|Mutex to make stopBool thread safe. |
|Boolean value indication that handler() should terminate. |
|Mutex to make terminateMutex thread safe. |
|static void||signalHandler (int signum)|
|General function to handler POSIX signals. |
|static ManagerPar *||instance = 0|
|Pointer to the Manager object. |
General task and protocol management class.
Handles all task and protocol management, creation/destruction of requests and passing of messages to requests. The template argument should be a class type derived from the Request class with at least the response() function defined. To operate this class all that needs to be done is creating an object and calling handler() on it.
|T||Class that will handle individual requests. Should be derived from the Request class.|
|const boost::function< void(Protocol::FullId, Message)> &||sendMessage_,|
Construct from a file descriptor.
The only piece of data required to construct a Manager object is a file descriptor to listen on for incoming connections. By default mod_fastcgi sets up file descriptor 0 to do this so it is the value passed by default to the constructor. The only time it would be another value is if an external FastCGI server was defined.
|[in]||fd||File descriptor to listen on.|
|[in]||sendMessage_||Function Transceiver should use to communicate with Manager.|
|[in]||doSetupSignals||If true, signal handlers will be set up for SIGTERM and SIGUSR1. If false, no signal handlers will be set up.|
|size_t Fastcgipp::ManagerPar::getMessagesSize||(||)|| const
Handles management messages.
This function is called by handler() in the case that a management message is recieved. Although the request id of a management record is always 0, the Protocol::FullId associated with the message is passed to this function to keep track of it's associated file descriptor.
|[in]||id||FullId associated with the messsage.|
References Fastcgipp::Message::data, Fastcgipp::Block::data, Fastcgipp::Protocol::GET_VALUES, Fastcgipp::Protocol::maxConnsReply, Fastcgipp::Protocol::maxReqsReply, Fastcgipp::Protocol::mpxsConnsReply, Fastcgipp::Protocol::processParamHeader(), Fastcgipp::Protocol::UNKNOWN_TYPE, and Fastcgipp::Protocol::version.
Configure the handlers for POSIX signals.
By calling this function appropriate handlers will be set up for SIGPIPE, SIGUSR1 and SIGTERM. It is called by default upon construction of a Manager object. Should the user want to override these handlers, it should be done post-construction.
Referenced by ManagerPar().
Halter for the handler() function.
This function is intended to be called from a thread separate from the handler() in order to halt it. It should also be called by a signal handler in the case of of a SIGTERM. Once handler() has been halted it may be re-called to pick up exactly where it left off without any data loss.
Terminator for the handler() function.
This function is intended to be called from a signal handler in the case of of a SIGUSR1. It is similar to stop() except that handler() will wait until all requests are complete before halting.
The pthread id of the thread the handler() function is operating in.
Although this library is intended to be used with boost::thread and not pthread, the underlying pthread id of the handler() function is needed to call pthread_kill() when sleep is to be interrupted.