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

I/O handler for accept (listen) sockets. More...

#include <IOHandlerAccept.h>

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

Public Member Functions

 IOHandlerAccept (int sd, const DispatchHandlerPtr &dhp, HandlerMapPtr &hmap, ConnectionHandlerFactoryPtr &chfp)
 Constructor. More...
 
virtual ~IOHandlerAccept ()
 Destructor. More...
 
bool handle_event (struct pollfd *event, ClockT::time_point arrival_time) override
 Handle poll() interface events. 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 Member Functions

bool handle_incoming_connection ()
 Handles incoming connection requests. More...
 

Private Attributes

HandlerMapPtr m_handler_map
 Handler map. More...
 
ConnectionHandlerFactoryPtr m_handler_factory
 Connection handler factory for creating default dispatch handlers for incoming connections. 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 accept (listen) sockets.

Definition at line 43 of file IOHandlerAccept.h.

Constructor & Destructor Documentation

Hypertable::IOHandlerAccept::IOHandlerAccept ( int  sd,
const DispatchHandlerPtr dhp,
HandlerMapPtr hmap,
ConnectionHandlerFactoryPtr chfp 
)
inline

Constructor.

Initializes member variables and sets m_local_addr to the address of sd obtained via getsockname.

Parameters
sdSocket descriptor on which listen has been called
dhpReference to default dispatch handler
hmapReference to Handler map
chfpReference to connection handler factory

Definition at line 54 of file IOHandlerAccept.h.

virtual Hypertable::IOHandlerAccept::~IOHandlerAccept ( )
inlinevirtual

Destructor.

Definition at line 61 of file IOHandlerAccept.h.

Member Function Documentation

bool IOHandlerAccept::handle_event ( struct pollfd *  event,
ClockT::time_point  arrival_time 
)
overridevirtual

Handle poll() interface events.

This method handles POLLIN by calling handle_incoming_connection. Any other event is considered an error and is handled by decomissioning the handler.

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

Implements Hypertable::IOHandler.

Definition at line 60 of file IOHandlerAccept.cc.

bool IOHandlerAccept::handle_incoming_connection ( )
private

Handles incoming connection requests.

This method is called in response to events that signal incoming connection requests. It performs the following actions in a loop:

  • Calls accept (returns on EAGAIN)
  • On the socket returned by accept
    • Sets O_NONBLOCK option
    • Sets TCP_NODELAY option (Linux and Sun)
    • Sets SO_NOSIGPIPE option (Apple and FreeBSD)
    • Sets socket send and receive buffers to 4*32768
  • Creates a default dispatch handler using m_handler_factory
  • Creates an IOHandlerData object with socket returned by accept and default dispatch handler
  • Inserts newly created handler in m_handler_map
  • If proxy master, propagate proxy map over newly established connection.
  • Starts polling on newly created handler with PollEvent::READ and PollEvent::WRITE interest
  • Delivers Event::CONNECTION_ESTABLISHED event

Definition at line 100 of file IOHandlerAccept.cc.

Member Data Documentation

Hypertable::IOHandlerAccept::ImplementMe

Definition at line 112 of file IOHandlerAccept.h.

ConnectionHandlerFactoryPtr Hypertable::IOHandlerAccept::m_handler_factory
private

Connection handler factory for creating default dispatch handlers for incoming connections.

Definition at line 144 of file IOHandlerAccept.h.

HandlerMapPtr Hypertable::IOHandlerAccept::m_handler_map
private

Handler map.

Definition at line 139 of file IOHandlerAccept.h.


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