I/O handler for raw sockets. More...
#include <IOHandlerRaw.h>
Public Member Functions | |
IOHandlerRaw (int sd, const InetAddr &addr, RawSocketHandler *rhp) | |
Constructor. More... | |
virtual | ~IOHandlerRaw () |
Destructor. More... | |
bool | handle_event (struct pollfd *event, ClockT::time_point arrival_time) override |
Handle poll() interface events. More... | |
void | update_poll_interest () |
Updates polling interest for socket. More... | |
Public Member Functions inherited from Hypertable::IOHandler | |
IOHandler (int sd, const DispatchHandlerPtr &dhp, Reactor::Priority rp=Reactor::Priority::NORMAL) | |
Constructor. More... | |
IOHandler (int sd) | |
Constructor. More... | |
virtual | ~IOHandler () |
Destructor. More... | |
void | deliver_event (EventPtr &event, DispatchHandler *dh=0) |
Convenience method for delivering event to application. More... | |
int | start_polling (int mode=PollEvent::READ) |
Start polling on the handler with the poll interest specified in mode . More... | |
int | add_poll_interest (int mode) |
Adds the poll interest specified in mode to the polling interface for this handler. More... | |
int | remove_poll_interest (int mode) |
Removes the poll interest specified in mode to the polling interface for this handler. More... | |
int | reset_poll_interest () |
Resets poll interest by adding m_poll_interest to the polling interface for this handler. More... | |
InetAddr | get_address () |
Gets the handler socket address. More... | |
InetAddr | get_local_address () |
Get local socket address for connection. More... | |
void | set_proxy (const String &proxy) |
Sets the proxy name for this connection. More... | |
const String & | get_proxy () |
Gets the proxy name for this connection. More... | |
int | get_sd () |
Gets the socket descriptor for this connection. More... | |
void | get_reactor (ReactorPtr &reactor) |
Get the reactor that this handler is assigned to. More... | |
void | display_event (struct pollfd *event) |
Display polling event from poll() interface to stderr. More... | |
Public Attributes | |
ImplementMe | |
Private Attributes | |
RawSocketHandler * | m_handler |
Raw socket handler. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from Hypertable::IOHandler | |
bool | test_and_set_error (int32_t error) |
Sets m_error to error if it has not already been set. More... | |
int32_t | get_error () |
Returns first error code encountered by handler. More... | |
InetAddr | get_alias () |
Get alias address for this connection. More... | |
void | set_alias (const InetAddr &alias) |
Set alias address for this connection. More... | |
void | increment_reference_count () |
Increment reference count. More... | |
void | decrement_reference_count () |
Decrement reference count. More... | |
size_t | reference_count () |
Return reference count. More... | |
void | decomission () |
Decomission handler. More... | |
bool | is_decomissioned () |
Checks to see if handler is decomissioned. More... | |
virtual void | disconnect () |
Disconnect connection. More... | |
short | poll_events (int mode) |
Return poll() interface events corresponding to the normalized polling interest in mode . More... | |
void | stop_polling () |
Stops polling by removing socket from polling interface. More... | |
Protected Attributes inherited from Hypertable::IOHandler | |
std::mutex | m_mutex |
Mutex for serializing concurrent access More... | |
size_t | m_reference_count |
Reference count. More... | |
uint32_t | m_free_flag |
Free flag (for testing) More... | |
int32_t | m_error |
Error code. More... | |
String | m_proxy |
Proxy name for this connection. More... | |
InetAddr | m_addr |
Handler socket address. More... | |
InetAddr | m_local_addr |
Local address of connection. More... | |
InetAddr | m_alias |
Address alias for connection. More... | |
int | m_sd |
Socket descriptor. More... | |
DispatchHandlerPtr | m_dispatch_handler |
Default dispatch hander for connection. More... | |
ReactorPtr | m_reactor |
Reactor to which this handler is assigned. More... | |
int | m_poll_interest |
Current polling interest. More... | |
bool | m_decomissioned |
Decomissioned flag. More... | |
bool m_socket_internally_created | true |
Socket was internally created and should be closed on destroy. More... | |
I/O handler for raw sockets.
Definition at line 42 of file IOHandlerRaw.h.
|
inline |
Constructor.
Initializes handler by setting #m_socket_internally_created to false and setting m_addr to addr
.
sd | Socket descriptor |
addr | Connection address for identification purposes |
rhp | Poiner to raw socket handler |
Definition at line 52 of file IOHandlerRaw.h.
|
inlinevirtual |
Destructor.
Calls the RawSocketHandler::deregister() function of m_handler.
Definition at line 60 of file IOHandlerRaw.h.
|
overridevirtual |
Handle poll()
interface events.
This method is called by its reactor thread to handle I/O events. It handles POLLERR
and POLLHUP
events by decomissing the handler and returning true causing the reactor runner to remove the socket from the event loop. It handles POLLIN
and POLLOUT
events by passing them to the RawSocketHandler::handle() function of m_handler and then calling update_poll_interest() to update the polling interest.
event | Pointer to pollfd structure describing event |
arrival_time | Time of event arrival |
Implements Hypertable::IOHandler.
Definition at line 59 of file IOHandlerRaw.cc.
void IOHandlerRaw::update_poll_interest | ( | ) |
Updates polling interest for socket.
This function is called after the RawSocketHandler::handle() function is called to updated the polling interest of the socket. It first calls RawSocketHandler::poll_interest() to obtain the new polling interest. Based on the difference between the existing polling interest registered for the socket and the new interest returned by RawSocketHandler::poll_interest(), calls remove_poll_interest() and add_poll_interest() to adjust the polling interest for the socket.
Definition at line 253 of file IOHandlerRaw.cc.
Hypertable::IOHandlerRaw::ImplementMe |
Definition at line 129 of file IOHandlerRaw.h.
|
private |
Raw socket handler.
Definition at line 145 of file IOHandlerRaw.h.