fastcgi++
|
Handles low level communication with "the other side". More...
#include <transceiver.hpp>
Classes | |
class | Buffer |
Buffer type for transmission of FastCGI records More... | |
struct | fdBuffer |
Buffer type for receiving FastCGI records More... |
Public Member Functions | |
bool | handler () |
General transceiver handler. | |
Block | requestWrite (size_t size) |
Direct interface to Buffer::requestWrite() | |
void | secureWrite (size_t size, Protocol::FullId id, bool kill) |
Direct interface to Buffer::secureWrite() | |
Transceiver (int fd_, boost::function< void(Protocol::FullId, Message)> sendMessage_) | |
Constructor. | |
void | sleep () |
Blocks until there is data to receive or a call to wake() is made. | |
void | wake () |
Forces a wakeup from a call to sleep() | |
void | freeFd (int fd_) |
Helper function for freeFd(int fd, std::vector<pollfd> pollFds, std::map<int, fdBuffer> fdBuffers) |
Static Public Member Functions | |
static void | freeFd (int fd, std::vector< pollfd > &pollFds, std::map< int, fdBuffer > &fdBuffers) |
Free fd/pipe and all it's associated resources. |
Private Member Functions | |
int | transmit () |
Transmit all buffered data possible. |
Private Attributes | |
Buffer | buffer |
Buffer for transmitting data | |
boost::function< void(Protocol::FullId, Message)> | sendMessage |
Function to call to pass messages to requests. | |
std::vector< pollfd > | pollFds |
poll() file descriptors container | |
int | socket |
Socket to listen for connections on. | |
int | wakeUpFdIn |
Input file descriptor to the wakeup socket pair. | |
int | wakeUpFdOut |
Output file descriptor to the wakeup socket pair. | |
std::map< int, fdBuffer > | fdBuffers |
Container associating file descriptors with their receive buffers. |
Handles low level communication with "the other side".
This class handles the sending/receiving/buffering of data through the OS level sockets and also the creation/destruction of the sockets themselves.
Definition at line 79 of file transceiver.hpp.
Fastcgipp::Transceiver::Transceiver | ( | int | fd_, |
boost::function< void(Protocol::FullId, Message)> | sendMessage_ | ||
) |
Constructor.
Construct a transceiver object based on an initial file descriptor to listen on and a function to pass messages on to.
[in] | fd_ | File descriptor to listen for connections on |
[in] | sendMessage_ | Function to call to pass messages to requests |
Definition at line 195 of file transceiver.cpp.
References pollFds, socket, wakeUpFdIn, and wakeUpFdOut.
|
static |
Free fd/pipe and all it's associated resources.
By calling this function you close the passed file descriptor and free up it's associated buffers and resources. It is safe to call this function at any time with any fd(even bad ones). If requests still exists with this fd then they will be lost.
fd | File descriptor to delete/free up |
pollFds | Epoll container |
fdBuffers | Container of fd/pipe buffers |
Definition at line 316 of file transceiver.cpp.
Referenced by transmit().
|
inline |
bool Fastcgipp::Transceiver::handler | ( | ) |
General transceiver handler.
This function is called by Manager::handler() to both transmit data passed to it from requests and relay received data back to them as a Message. The function will return true if there is nothing at all for it to do.
Definition at line 64 of file transceiver.cpp.
References Fastcgipp::reventsZero(), Fastcgipp::Message::size, and Fastcgipp::Message::type.
|
inline |
Direct interface to Buffer::requestWrite()
Definition at line 93 of file transceiver.hpp.
References buffer, and Fastcgipp::Transceiver::Buffer::requestWrite().
|
inline |
Direct interface to Buffer::secureWrite()
Definition at line 95 of file transceiver.hpp.
References buffer, Fastcgipp::Transceiver::Buffer::secureWrite(), and transmit().
|
inline |
Blocks until there is data to receive or a call to wake() is made.
Definition at line 106 of file transceiver.hpp.
References pollFds.
|
private |
Transmit all buffered data possible.
Definition at line 24 of file transceiver.cpp.
References buffer, Fastcgipp::Transceiver::Buffer::empty(), freeFd(), Fastcgipp::Transceiver::Buffer::freeRead(), and Fastcgipp::Transceiver::Buffer::requestRead().
Referenced by secureWrite().
void Fastcgipp::Transceiver::wake | ( | ) |
Forces a wakeup from a call to sleep()
Definition at line 189 of file transceiver.cpp.
|
private |
Buffer for transmitting data
Definition at line 258 of file transceiver.hpp.
Referenced by requestWrite(), secureWrite(), and transmit().
|
private |
Container associating file descriptors with their receive buffers.
Definition at line 272 of file transceiver.hpp.
Referenced by freeFd().
|
private |
poll() file descriptors container
Definition at line 263 of file transceiver.hpp.
Referenced by freeFd(), sleep(), and Transceiver().
|
private |
Function to call to pass messages to requests.
Definition at line 260 of file transceiver.hpp.
|
private |
Socket to listen for connections on.
Definition at line 265 of file transceiver.hpp.
Referenced by Transceiver().
|
private |
Input file descriptor to the wakeup socket pair.
Definition at line 267 of file transceiver.hpp.
Referenced by Transceiver().
|
private |
Output file descriptor to the wakeup socket pair.
Definition at line 269 of file transceiver.hpp.
Referenced by Transceiver().