34 std::unique_ptr<Record> record;
58 #if FASTCGIPP_LOG_LEVEL > 3 65 #if FASTCGIPP_LOG_LEVEL > 3 66 ++m_connectionKillCount;
124 ,m_connectionKillCount(0),
125 m_connectionRDHupCount(0),
131 DIAG_LOG(
"Transceiver::Transciever(): Initialized")
145 const ssize_t read = socket.
read(
160 +reinterpret_cast<Protocol::Header*>(
161 buffer.
begin())->contentLength
162 +reinterpret_cast<Protocol::Header*>(
163 buffer.
begin())->paddingLength);
168 const ssize_t read = socket.
read(
182 message.
data = std::move(buffer);
187 #if FASTCGIPP_LOG_LEVEL > 3 200 #if FASTCGIPP_LOG_LEVEL > 3 201 ++m_connectionRDHupCount;
210 std::unique_ptr<Record> record(
new Record(
219 #if FASTCGIPP_LOG_LEVEL > 3 227 DIAG_LOG(
"Transceiver::~Transceiver(): Locally closed sockets ==== " \
228 << m_connectionKillCount)
229 DIAG_LOG(
"Transceiver::~Transceiver(): Remotely closed sockets === " \
230 << m_connectionRDHupCount)
231 DIAG_LOG(
"Transceiver::~Transceiver(): Remaining receive buffers = " \
233 DIAG_LOG(
"Transceiver::~Transceiver(): Records queued === " \
235 DIAG_LOG(
"Transceiver::~Transceiver(): Records sent ===== " \
237 DIAG_LOG(
"Transceiver::~Transceiver(): Records received = " \
238 << m_recordsReceived)
void send(const Socket &socket, Block &&data, bool kill)
Queue up a block of data for transmission.
void close() const
Call this to close the socket.
std::deque< std::unique_ptr< Record > > m_sendBuffer
Buffer for transmitting data
void handler()
General transceiver handler.
void header(Level level)
Send a log header to logstream.
void join()
Block until a stop() or terminate() is called and completed.
void cleanupSocket(const Socket &socket)
Cleanup a dead socket.
Data structure used to pass messages to requests.
SocketGroup m_sockets
Listen for connections with this.
size_t size() const
See the relevant data size.
ssize_t read(char *buffer, size_t size) const
Try and read a chunk of data out of the socket.
Transceiver(const std::function< void(Protocol::RequestId, Message &&)> sendMessage)
Constructor.
bool valid() const
Returns true if this socket is still open and capable of read/write.
void accept(bool status)
Should we accept new connections?
std::thread m_thread
Thread our handler is running in.
#define FASTCGIPP_LOG_LEVEL
const uint16_t badFcgiId
Constant that defines a bad/special FcgiId.
size_t reserve() const
See the reserve size.
const std::function< void(Protocol::RequestId, Message &&)> m_sendMessage
Function to call to pass messages to requests.
std::atomic_bool m_terminate
True when handler() should be terminating.
void terminate()
Call from any thread to terminate the handler() thread.
void wake()
Wake up from a nap inside poll()
Simple FastCGI record to queue up for transmission.
void start()
Call from any thread to start the handler() thread.
std::map< Socket, Block > m_receiveBuffers
Container associating sockets with their receive buffers.
Class for representing an OS level I/O socket.
void receive(Socket &socket)
Receive data on the specified socket.
Socket poll(bool block)
Poll socket set for new incoming connections and data.
A unique identifier for each FastCGI request.
Block data
The raw data being passed along with the message.
void stop()
Call from any thread to stop the handler() thread.
std::atomic_bool m_stop
True when handler() should be stopping.
ssize_t write(const char *buffer, size_t size) const
Try and write a chunk of data into the socket.
bool transmit()
Transmit all buffered data possible.
Declares the Fastcgipp::Transceiver class.
size_t size() const
How many active sockets (not counting listeners) are in the group.
char * end()
Pointer to 1+ the last element.
Declares the Fastcgipp debugging/logging facilities.
std::mutex m_sendBufferMutex
Thread safe the send buffer.
Data structure to hold a block of raw data.
char * begin()
Pointer to the first element.