*
* Ported by Peter Payne from Squid 2.7.STABLE9 comm_devpoll.c
* on August 11, 2010 at 3pm (GMT+0100 Europe/London).
- *
- * Last modified 2010-10-08
*/
-
/*
* There are several poll types in Squid, ALL of which are compiled and linked
* in. Thus conditional compile-time flags are used to prevent the different
#define DEBUG_DEVPOLL 0
-// OPEN_MAX is defined in <climits>
-#define DEVPOLL_UPDATESIZE OPEN_MAX
-#define DEVPOLL_QUERYSIZE OPEN_MAX
-
/* TYPEDEFS */
typedef short pollfd_events_t; /* type of pollfd.events from sys/poll.h */
* @param events events to register (usually POLLIN, POLLOUT, or POLLREMOVE)
*/
static void
-comm_update_fd(int fd, int events)
+comm_update_fd(int fd, pollfd_events_t events)
{
debugs(
5,
/* allocate memory first before attempting to open poll device */
/* This tracks the FD devpoll offset+state */
devpoll_state = (struct _devpoll_state *)xcalloc(
- SQUID_MAXFD, sizeof(struct _devpoll_state)
+ Squid_MaxFD, sizeof(struct _devpoll_state)
);
- /* And this is the stuff we use to read events */
+ /* This is the stuff we use to read events. If it's larger than
+ the current RLIMIT_NOFILE, the Solaris kernel returns EINVAL. */
+ dpoll_nfds = Squid_MaxFD;
do_poll.dp_fds = (struct pollfd *)xcalloc(
- DEVPOLL_QUERYSIZE, sizeof(struct pollfd)
+ dpoll_nfds, sizeof(struct pollfd)
);
- dpoll_nfds = DEVPOLL_QUERYSIZE;
+ /* This is the stuff we use to write requests to change tracking state.
+ It's also limited to the current RLIMIT_NOFILE by the Solaris kernel. */
+ devpoll_update.cur = -1;
+ devpoll_update.size = Squid_MaxFD;
devpoll_update.pfds = (struct pollfd *)xcalloc(
- DEVPOLL_UPDATESIZE, sizeof(struct pollfd)
+ devpoll_update.size, sizeof(struct pollfd)
);
- devpoll_update.cur = -1;
- devpoll_update.size = DEVPOLL_UPDATESIZE;
/* attempt to open /dev/poll device */
devpoll_fd = open("/dev/poll", O_RDWR);