0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Member Functions | Public Attributes | Private Attributes | List of all members
Hypertable::IOHandlerRaw Class Reference

I/O handler for raw sockets. More...

#include <IOHandlerRaw.h>

Inheritance diagram for Hypertable::IOHandlerRaw:
Inheritance graph
[legend]
Collaboration diagram for Hypertable::IOHandlerRaw:
Collaboration graph
[legend]

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 Stringget_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

RawSocketHandlerm_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...
 

Detailed Description

I/O handler for raw sockets.

Definition at line 42 of file IOHandlerRaw.h.

Constructor & Destructor Documentation

Hypertable::IOHandlerRaw::IOHandlerRaw ( int  sd,
const InetAddr addr,
RawSocketHandler rhp 
)
inline

Constructor.

Initializes handler by setting #m_socket_internally_created to false and setting m_addr to addr.

Parameters
sdSocket descriptor
addrConnection address for identification purposes
rhpPoiner to raw socket handler

Definition at line 52 of file IOHandlerRaw.h.

virtual Hypertable::IOHandlerRaw::~IOHandlerRaw ( )
inlinevirtual

Destructor.

Calls the RawSocketHandler::deregister() function of m_handler.

Definition at line 60 of file IOHandlerRaw.h.

Member Function Documentation

bool IOHandlerRaw::handle_event ( struct pollfd *  event,
ClockT::time_point  arrival_time 
)
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.

Parameters
eventPointer to pollfd structure describing event
arrival_timeTime of event arrival
Returns
false on success, true if error encountered and handler was decomissioned

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.

Member Data Documentation

Hypertable::IOHandlerRaw::ImplementMe

Definition at line 129 of file IOHandlerRaw.h.

RawSocketHandler* Hypertable::IOHandlerRaw::m_handler
private

Raw socket handler.

Definition at line 145 of file IOHandlerRaw.h.


The documentation for this class was generated from the following files: