I/O handler for accept (listen) sockets. More...
#include <IOHandlerAccept.h>


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 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 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... | |
I/O handler for accept (listen) sockets.
Definition at line 43 of file IOHandlerAccept.h.
|
inline |
Constructor.
Initializes member variables and sets m_local_addr to the address of sd obtained via getsockname.
| sd | Socket descriptor on which listen has been called |
| dhp | Reference to default dispatch handler |
| hmap | Reference to Handler map |
| chfp | Reference to connection handler factory |
Definition at line 54 of file IOHandlerAccept.h.
|
inlinevirtual |
Destructor.
Definition at line 61 of file IOHandlerAccept.h.
|
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.
| event | Pointer to pollfd structure describing event |
| arrival_time | Time of event arrival (not used) |
Implements Hypertable::IOHandler.
Definition at line 60 of file IOHandlerAccept.cc.
|
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:
accept (returns on EAGAIN)acceptO_NONBLOCK optionTCP_NODELAY option (Linux and Sun)SO_NOSIGPIPE option (Apple and FreeBSD)4*32768accept and default dispatch handlerDefinition at line 100 of file IOHandlerAccept.cc.
| Hypertable::IOHandlerAccept::ImplementMe |
Definition at line 112 of file IOHandlerAccept.h.
|
private |
Connection handler factory for creating default dispatch handlers for incoming connections.
Definition at line 144 of file IOHandlerAccept.h.
|
private |
Handler map.
Definition at line 139 of file IOHandlerAccept.h.
1.8.8