/*
- * $Id$
- *
- * DEBUG: section 05 Socket Functions
- *
- * SQUID Web Proxy Cache http://www.squid-cache.org/
- * ----------------------------------------------------------
- *
- * Squid is the result of efforts by numerous individuals from
- * the Internet community; see the CONTRIBUTORS file for full
- * details. Many organizations have provided support for Squid's
- * development; see the SPONSORS file for full details. Squid is
- * Copyrighted (C) 2001 by the Regents of the University of
- * California; see the COPYRIGHT file for full details. Squid
- * incorporates software developed and/or copyrighted by other
- * sources; see the CREDITS file for full details.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
*
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
*/
+
+/* DEBUG: section 05 Socket Functions */
+
#include "squid.h"
#if USE_POLL
#include "anyp/PortCfg.h"
#include "comm/Connection.h"
#include "comm/Loops.h"
+#include "fd.h"
#include "fde.h"
#include "globals.h"
#include "ICP.h"
#include "mgr/Registration.h"
#include "profiler/Profiler.h"
-#include "protos.h"
+#include "SquidConfig.h"
#include "SquidTime.h"
#include "StatCounters.h"
#include "Store.h"
+#include <cerrno>
#if HAVE_POLL_H
#include <poll.h>
#endif
-#if HAVE_ERRNO_H
-#include <errno.h>
-#endif
/* Needed for poll() on Linux at least */
#if USE_POLL
#endif
#endif
-static int MAX_POLL_TIME = 1000; /* see also Comm::QuickPollRequired() */
+static int MAX_POLL_TIME = 1000; /* see also Comm::QuickPollRequired() */
#ifndef howmany
#define howmany(x, y) (((x)+((y)-1))/(y))
static int
fdIsTcpListen(int fd)
{
- for (const AnyP::PortCfg *s = Config.Sockaddr.http; s; s = s->next) {
+ for (AnyP::PortCfgPointer s = HttpPortList; s != NULL; s = s->next) {
if (s->listenConn != NULL && s->listenConn->fd == fd)
return 1;
}
}
/* poll all sockets; call handlers for those that are ready. */
-comm_err_t
+Comm::Flag
Comm::DoSelect(int msec)
{
struct pollfd pfds[SQUID_MAXFD];
*/
if (nfds == 0 && npending == 0) {
if (shutting_down)
- return COMM_SHUTDOWN;
+ return Comm::SHUTDOWN;
else
- return COMM_IDLE;
+ return Comm::IDLE;
}
for (;;) {
PROF_start(comm_poll_normal);
++ statCounter.syscalls.selects;
num = poll(pfds, nfds, msec);
+ int xerrno = errno;
++ statCounter.select_loops;
PROF_stop(comm_poll_normal);
if (num >= 0 || npending > 0)
break;
- if (ignoreErrno(errno))
+ if (ignoreErrno(xerrno))
continue;
- debugs(5, DBG_CRITICAL, "comm_poll: poll failure: " << xstrerror());
+ debugs(5, DBG_CRITICAL, MYNAME << "poll failure: " << xstrerr(xerrno));
- assert(errno != EINVAL);
+ assert(xerrno != EINVAL);
- return COMM_ERROR;
+ return Comm::COMM_ERROR;
/* NOTREACHED */
}
if ((hdl = F->read_handler)) {
PROF_start(comm_read_handler);
F->read_handler = NULL;
- F->flags.read_pending = 0;
+ F->flags.read_pending = false;
hdl(fd, F->read_data);
PROF_stop(comm_read_handler);
++ statCounter.select_fds;
statCounter.select_time += (current_dtime - start);
- return COMM_OK;
+ return Comm::OK;
} while (timeout > current_dtime);
debugs(5, 8, "comm_poll: time out: " << squid_curtime << ".");
- return COMM_TIMEOUT;
+ return Comm::TIMEOUT;
}
static void
}
#endif /* USE_POLL */
+