Go to the documentation of this file.
34 #define POLLRDNORM POLLIN
37 #define POLLWRNORM POLLOUT
44 #define howmany(x, y) (((x)+((y)-1))/(y))
49 #define FD_MASK_BYTES sizeof(fd_mask)
50 #define FD_MASK_BITS (FD_MASK_BYTES*NBBY)
61 Comm::SetSelect(
int fd,
unsigned int type,
PF * handler,
void *client_data, time_t timeout)
65 assert(
F->flags.open || (!handler && !client_data && !timeout));
66 debugs(5, 5,
"FD " << fd <<
", type=" << type <<
67 ", handler=" << handler <<
", client_data=" << client_data <<
68 ", timeout=" << timeout);
71 F->read_handler = handler;
72 F->read_data = client_data;
76 F->write_handler = handler;
77 F->write_data = client_data;
112 if (s->listenConn !=
nullptr && s->listenConn->fd == fd)
130 for (i = npfds = 0; i < nfds; ++i) {
143 pfds[npfds].events = events;
144 pfds[npfds].revents = 0;
155 if (poll(
pfds, npfds, 0) < 1)
158 for (i = 0; i < npfds; ++i) {
161 if (((revents =
pfds[i].revents) == 0) || ((fd =
pfds[i].fd) == -1))
164 if (revents & (
POLLRDNORM | POLLIN | POLLHUP | POLLERR)) {
165 if ((hdl =
fd_table[fd].read_handler)) {
166 fd_table[fd].read_handler =
nullptr;
172 if (revents & (
POLLWRNORM | POLLOUT | POLLHUP | POLLERR)) {
173 if ((hdl =
fd_table[fd].write_handler)) {
174 fd_table[fd].write_handler =
nullptr;
216 fds[nfds] = s->listenConn->fd;
231 struct pollfd
pfds[SQUID_MAXFD];
237 unsigned long npending;
239 int calldns = 0, calludp = 0, calltcp = 0;
256 calldns = calludp = calltcp = 0;
264 for (
int i = 0; i < maxfd; ++i) {
277 pfds[nfds].events = events;
278 pfds[nfds].revents = 0;
297 if (nfds == 0 && npending == 0) {
306 num = poll(
pfds, nfds, msec);
310 if (num >= 0 || npending > 0)
327 debugs(5, num ? 5 : 8,
"comm_poll: " << num <<
"+" << npending <<
" FDs ready");
330 if (num == 0 && npending == 0)
337 for (
size_t loopIndex = 0; loopIndex < nfds; ++loopIndex) {
339 int revents =
pfds[loopIndex].revents;
340 fd =
pfds[loopIndex].fd;
345 if (
fd_table[fd].flags.read_pending)
368 if (revents & (
POLLRDNORM | POLLIN | POLLHUP | POLLERR)) {
369 debugs(5, 6,
"comm_poll: FD " << fd <<
" ready for reading");
371 if ((hdl =
F->read_handler)) {
372 F->read_handler =
nullptr;
373 hdl(fd,
F->read_data);
387 if (revents & (
POLLWRNORM | POLLOUT | POLLHUP | POLLERR)) {
388 debugs(5, 6,
"comm_poll: FD " << fd <<
" ready for writing");
390 if ((hdl =
F->write_handler)) {
391 F->write_handler =
nullptr;
392 hdl(fd,
F->write_data);
406 if (revents & POLLNVAL) {
412 F->read_handler <<
" write:" <<
F->write_handler);
414 for (ch =
F->closeHandler; ch !=
nullptr; ch = ch->
Next())
417 if (
F->closeHandler !=
nullptr) {
419 }
else if (
F->timeoutHandler !=
nullptr) {
424 F->closeHandler =
nullptr;
425 F->timeoutHandler =
nullptr;
426 F->read_handler =
nullptr;
427 F->write_handler =
nullptr;
481 "comm_incoming() stats",
502 storeAppendPrintf(sentry,
"ICP Messages handled per comm_poll_udp_incoming() call:\n");
504 storeAppendPrintf(sentry,
"DNS Messages handled per comm_poll_dns_incoming() call:\n");
506 storeAppendPrintf(sentry,
"HTTP Messages handled per comm_poll_tcp_incoming() call:\n");
const char * xstrerr(int error)
double current_dtime
the current UNIX time in seconds (with microsecond precision)
int incoming_sockets_accepted
AnyP::PortCfgPointer HttpPortList
list of Squid http(s)_port configured
static OBJH commIncomingStats
#define ScheduleCallHere(call)
void storeAppendPrintf(StoreEntry *e, const char *fmt,...)
void commCallCloseHandlers(int fd)
static int fdIsDns(int fd)
struct SquidConfig::CommIncoming comm_incoming
Comm::ConnectionPointer icpOutgoingConn
Comm::Flag DoSelect(int)
Do poll and trigger callback functions as appropriate.
static void comm_poll_dns_incoming(void)
static uint32 F(uint32 X, uint32 Y, uint32 Z)
static void comm_poll_tcp_incoming(void)
bool IsConnOpen(const Comm::ConnectionPointer &conn)
struct SquidConfig::CommIncoming::Measure udp
struct StatCounters::@119 syscalls
time_t getCurrentTime() STUB_RETVAL(0) int tvSubUsec(struct timeval
void dump(StoreEntry *sentry, StatHistBinDumper *bd) const
static void commPollRegisterWithCacheManager(void)
struct SquidConfig::CommIncoming::Measure dns
static int fdIsUdpListen(int fd)
static int comm_check_incoming_poll_handlers(int nfds, int *fds)
static int fdIsTcpListen(int fd)
void SelectLoopInit(void)
Initialize the module on Squid startup.
Comm::ConnectionPointer icpIncomingConn
int ignoreErrno(int ierrno)
struct SquidConfig::CommIncoming::Measure tcp
unsigned long int select_loops
StatHistBinDumper statHistIntDumper
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, Protected, Atomic, Format)
void finishPolling(int, SquidConfig::CommIncoming::Measure &)
void fd_close(const int fd)
AsyncCall::Pointer & Next()
#define MAXTCPLISTENPORTS
static void comm_poll_udp_incoming(void)
#define debugs(SECTION, LEVEL, CONTENT)
#define COMM_SELECT_WRITE
void QuickPollRequired(void)