Go to the documentation of this file.
43 #include <sys/event.h>
72 cur_handler =
fd_table[fd].read_handler;
76 cur_handler =
fd_table[fd].write_handler;
85 if ((cur_handler ==
NULL && handler !=
NULL)
86 || (cur_handler !=
NULL && handler ==
NULL)) {
92 if (handler !=
NULL) {
93 kep_flags = (EV_ADD | EV_ONESHOT);
95 kep_flags = EV_DELETE;
98 EV_SET(kep, (uintptr_t) fd, filter, kep_flags, 0, 0, 0);
108 perror(
"kq_update_events(): kevent()");
134 fatal(
"comm_select_init: Couldn't open kqueue fd!\n");
137 kqmax = getdtablesize();
153 Comm::SetSelect(
int fd,
unsigned int type,
PF * handler,
void *client_data, time_t timeout)
157 assert(
F->flags.open || (!handler && !client_data && !timeout));
158 debugs(5, 5,
"FD " << fd <<
", type=" << type <<
159 ", handler=" << handler <<
", client_data=" << client_data <<
160 ", timeout=" << timeout);
163 if (
F->flags.read_pending)
168 F->read_handler = handler;
169 F->read_data = client_data;
174 F->write_handler = handler;
175 F->write_data = client_data;
205 struct timespec poll_time;
210 poll_time.tv_sec = msec / 1000;
212 poll_time.tv_nsec = (msec % 1000) * 1000000;
237 for (i = 0; i < num; ++i) {
238 int fd = (
int) ke[i].ident;
242 if (ke[i].flags & EV_ERROR) {
248 if (ke[i].filter == EVFILT_READ ||
F->flags.read_pending) {
249 if ((hdl =
F->read_handler) !=
NULL) {
250 F->read_handler =
nullptr;
251 hdl(fd,
F->read_data);
255 if (ke[i].filter == EVFILT_WRITE) {
256 if ((hdl =
F->write_handler) !=
NULL) {
257 F->write_handler =
nullptr;
258 hdl(fd,
F->write_data);
262 if (ke[i].filter != EVFILT_WRITE && ke[i].filter != EVFILT_READ) {
void fatal(const char *message)
Comm::Flag DoSelect(int)
Do poll and trigger callback functions as appropriate.
static uint32 F(uint32 X, uint32 Y, uint32 Z)
static struct kevent * kqlst
static struct timespec zero_timespec
time_t getCurrentTime() STUB_RETVAL(0) int tvSubUsec(struct timeval
static void kq_update_events(int, short, PF *)
void SelectLoopInit(void)
Initialize the module on Squid startup.
int ignoreErrno(int ierrno)
unsigned long int select_loops
void SetSelect(int, unsigned int, PF *, void *, time_t)
Mark an FD to be watched for its IO status.
static void commKQueueRegisterWithCacheManager(void)
#define debugs(SECTION, LEVEL, CONTENT)
#define COMM_SELECT_WRITE
void QuickPollRequired(void)