43 #include <arpa/inet.h>
46 #include <sys/socket.h>
47 #include <sys/types.h>
48 #if defined(__APPLE__) || defined(__FreeBSD__)
49 #include <sys/event.h>
66 if (event->revents & POLLERR) {
67 HT_INFOF(
"Received POLLERR on descriptor %d (%s:%d)", m_sd,
68 inet_ntoa(m_addr.sin_addr), ntohs(m_addr.sin_port));
73 if (event->revents & POLLHUP) {
74 HT_DEBUGF(
"Received POLLHUP on descriptor %d (%s:%d)", m_sd,
75 inet_ntoa(m_addr.sin_addr), ntohs(m_addr.sin_port));
82 if (event->revents & POLLOUT)
85 if (event->revents & POLLIN)
88 if (!m_handler->handle(m_sd, events))
91 update_poll_interest();
103 #if defined(__linux__)
114 HT_DEBUGF(
"Received POLLRDHUP on descriptor %d (%s:%d)", m_sd,
115 inet_ntoa(m_addr.sin_addr), ntohs(m_addr.sin_port));
120 if (event->events & EPOLLERR) {
121 HT_INFOF(
"Received EPOLLERR on descriptor %d (%s:%d)", m_sd,
122 inet_ntoa(m_addr.sin_addr), ntohs(m_addr.sin_port));
127 if (event->events & EPOLLHUP) {
128 HT_DEBUGF(
"Received EPOLLHUP on descriptor %d (%s:%d)", m_sd,
129 inet_ntoa(m_addr.sin_addr), ntohs(m_addr.sin_port));
136 if (event->events & EPOLLOUT)
139 if (event->events & EPOLLIN)
142 if (!m_handler->handle(m_sd, events))
145 update_poll_interest();
157 #elif defined(__sun__)
166 if (event->portev_events & POLLERR) {
167 HT_INFOF(
"Received POLLERR on descriptor %d (%s:%d)", m_sd,
168 inet_ntoa(m_addr.sin_addr), ntohs(m_addr.sin_port));
173 if (event->portev_events & POLLHUP) {
174 HT_DEBUGF(
"Received POLLHUP on descriptor %d (%s:%d)", m_sd,
175 inet_ntoa(m_addr.sin_addr), ntohs(m_addr.sin_port));
180 if (event->portev_events & POLLREMOVE) {
181 HT_DEBUGF(
"Received POLLREMOVE on descriptor %d (%s:%d)", m_sd,
182 inet_ntoa(m_addr.sin_addr), ntohs(m_addr.sin_port));
189 if (event->portev_events & POLLOUT)
192 if (event->portev_events & POLLIN)
195 if (!m_handler->handle(m_sd, events))
198 update_poll_interest();
203 test_and_set_error(e.
code());
211 #elif defined(__APPLE__) || defined(__FreeBSD__)
219 assert(m_sd == (
int)event->ident);
221 if (event->flags & EV_EOF) {
228 if (event->filter == EVFILT_WRITE)
231 if (event->filter == EVFILT_READ)
234 if (!m_handler->handle(m_sd, events))
237 update_poll_interest();
242 test_and_set_error(e.
code());
255 int new_interest = m_handler->poll_interest(m_sd);
256 int changed = new_interest ^ m_poll_interest;
257 int turn_off = changed ^ new_interest;
258 int turn_on = changed ^ m_poll_interest;
259 int mask = ~(turn_off & turn_on);
263 HT_DEBUGF(
"Turning poll interest OFF: 0x%x", turn_off);
264 if ((error = remove_poll_interest(turn_off)) !=
Error::OK) {
271 HT_DEBUGF(
"Turning poll interest ON: 0x%x", turn_on);
272 if ((error = add_poll_interest(turn_on)) !=
Error::OK) {
chrono::time_point< fast_clock > time_point
Declarations for ReactorRunner.
static bool ms_epollet
Use "edge triggered" epoll.
Declarations for IOHandlerRaw.
void update_poll_interest()
Updates polling interest for socket.
static HandlerMapPtr handler_map
Smart pointer to HandlerMap.
File system utility functions.
Compatibility Macros for C/C++.
Declarations for PollEvent.
Time related declarations.
#define HT_DEBUGF(msg,...)
Writing can be performed without blocking.
#define HT_INFOF(msg,...)
Internet address wrapper classes and utility functions.
This is a generic exception class for Hypertable.
Error codes, Exception handling, error logging.
bool handle_event(struct pollfd *event, ClockT::time_point arrival_time) override
Handle poll() interface events.
int code() const
Returns the error code.