68 pevents = (
struct epoll_event *)
xmalloc(SQUID_MAXFD *
sizeof(
struct epoll_event));
72 fatalf(
"comm_select_init: xmalloc() failed: %s\n",
xstrerr(xerrno));
75 kdpfd = epoll_create(SQUID_MAXFD);
79 fatalf(
"comm_select_init: epoll_create(): %s\n",
xstrerr(xerrno));
90 return "EPOLL_CTL_ADD";
93 return "EPOLL_CTL_DEL";
96 return "EPOLL_CTL_MOD";
99 return "UNKNOWN_EPOLLCTL_OP";
111 int epoll_ctl_type = 0;
114 debugs(5, 5,
"FD " << fd <<
", type=" << type <<
115 ", handler=" <<
handler <<
", client_data=" << client_data <<
116 ", timeout=" << timeout);
118 struct epoll_event ev;
119 memset(&ev, 0,
sizeof(ev));
122 if (!
F->flags.open) {
123 epoll_ctl(
kdpfd, EPOLL_CTL_DEL, fd, &ev);
132 if (
F->flags.read_pending)
133 ev.events |= EPOLLOUT;
134 ev.events |= EPOLLIN;
139 F->read_data = client_data;
142 }
else if (
F->epoll_state & EPOLLIN) {
143 ev.events |= EPOLLIN;
149 ev.events |= EPOLLOUT;
153 F->write_data = client_data;
156 }
else if (
F->epoll_state & EPOLLOUT) {
157 ev.events |= EPOLLOUT;
161 ev.events |= EPOLLHUP | EPOLLERR;
163 if (ev.events !=
F->epoll_state) {
165 epoll_ctl_type = ev.events ? EPOLL_CTL_MOD : EPOLL_CTL_DEL;
167 epoll_ctl_type = EPOLL_CTL_ADD;
169 F->epoll_state = ev.events;
171 if (epoll_ctl(
kdpfd, epoll_ctl_type, fd, &ev) < 0) {
174 ",,): failed on FD " << fd <<
": " <<
xstrerr(xerrno));
184 F->codeContext =
nullptr;
194 "comm_incoming() stats",
224 struct epoll_event *cevents;
251 for (i = 0, cevents =
pevents; i < num; ++i, ++cevents) {
252 fd = cevents->data.fd;
256 std::hex << cevents->events <<
" monitoring=" <<
F->epoll_state <<
257 " F->read_handler=" <<
F->read_handler <<
" F->write_handler=" <<
F->write_handler);
261 if (cevents->events & (EPOLLIN|EPOLLHUP|EPOLLERR) ||
F->flags.read_pending) {
262 if ((hdl =
F->read_handler) !=
nullptr) {
264 F->read_handler =
nullptr;
265 hdl(fd,
F->read_data);
274 if (cevents->events & (EPOLLOUT|EPOLLHUP|EPOLLERR)) {
275 if ((hdl =
F->write_handler) !=
nullptr) {
277 F->write_handler =
nullptr;
278 hdl(fd,
F->write_data);
static struct epoll_event * pevents
static void commIncomingStats(StoreEntry *sentry)
static void commEPollRegisterWithCacheManager(void)
static const char * epolltype_atoi(int x)
StatHistBinDumper statHistIntDumper
static const Pointer & Current()
static void Reset()
forgets the current context, setting it to nil/unknown
unsigned long int select_loops
void dump(StoreEntry *sentry, StatHistBinDumper *bd) const
int ignoreErrno(int ierrno)
#define debugs(SECTION, LEVEL, CONTENT)
#define COMM_SELECT_WRITE
void fatalf(const char *fmt,...)
static uint32 F(uint32 X, uint32 Y, uint32 Z)
void QuickPollRequired(void)
Comm::Flag DoSelect(int)
Do poll and trigger callback functions as appropriate.
void SelectLoopInit(void)
Initialize the module on Squid startup.
void SetSelect(int, unsigned int, PF *, void *, time_t)
Mark an FD to be watched for its IO status.
void RegisterAction(char const *action, char const *desc, OBJH *handler, int pw_req_flag, int atomic)
static void handler(int signo)
void storeAppendPrintf(StoreEntry *e, const char *fmt,...)
time_t getCurrentTime() STUB_RETVAL(0) int tvSubUsec(struct timeval
const char * xstrerr(int error)