--- /dev/null
+#
+# lldp_CHECK_FD_SETSIZE
+#
+AC_DEFUN([lldp_CHECK_FD_SETSIZE],[
+ AC_CACHE_CHECK([real value of FD_SETSIZE], lldp_cv_check_fd_setsize, [
+ AC_RUN_IFELSE([
+ AC_LANG_PROGRAM(
+ [
+@%:@include <stdio.h>
+@%:@include <sys/select.h>
+@%:@include <sys/time.h>
+@%:@include <sys/types.h>
+@%:@include <unistd.h>
+ ],
+ [
+ FILE *fd;
+ if ((fd = fopen("conftest.out", "w")) == NULL) {
+ printf("Unable to create file conftest.out");
+ return 1;
+ }
+ fprintf(fd, "%d\n", FD_SETSIZE);
+ fclose(fd);
+ ])],
+ [ lldp_cv_check_fd_setsize=`cat conftest.out` ],
+ [ lldp_cv_check_fd_setsize="no" ])])
+ if test x"$lldp_cv_check_fd_setsize" = x"no"; then
+ AC_DEFINE([LLDPD_FD_SETSIZE], [FD_SETSIZE], [FD_SETSIZE for select()])
+ else
+ AC_DEFINE_UNQUOTED([LLDPD_FD_SETSIZE], $lldp_cv_check_fd_setsize,
+ [FD_SETSIZE for select()])
+ fi
+])
iface_fds_close(struct lldpd *cfg, struct lldpd_hardware *hardware)
{
int i;
- for (i=0; i < FD_SETSIZE; i++)
+ for (i=0; i < LLDPD_FD_SETSIZE; i++)
if (FD_ISSET(i, &hardware->h_recvfds)) {
FD_CLR(i, &hardware->h_recvfds);
close(i);
#include <arpa/inet.h>
#include <net/if_arp.h>
+#if LLDPD_FD_SETSIZE != FD_SETSIZE
+# warning "FD_SETSIZE is set to an inconsistent value."
+#endif
+
#ifdef USE_SNMP
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
hardware->h_ops->cleanup(cfg, hardware);
else {
free(hardware->h_data);
- for (i=0; i < FD_SETSIZE; i++)
+ for (i=0; i < LLDPD_FD_SETSIZE; i++)
if (FD_ISSET(i, &hardware->h_recvfds))
close(i);
if (hardware->h_sendfd) close(hardware->h_sendfd);
continue;
/* This is quite expensive but we don't rely on internal
* structure of fd_set. */
- for (n = 0; n < FD_SETSIZE; n++)
+ for (n = 0; n < LLDPD_FD_SETSIZE; n++)
if (FD_ISSET(n, &hardware->h_recvfds)) {
FD_SET(n, &rfds);
if (nfds < n)
}
#endif /* USE_SNMP */
TAILQ_FOREACH(hardware, &cfg->g_hardware, h_entries) {
- for (n = 0; n < FD_SETSIZE; n++)
+ for (n = 0; n < LLDPD_FD_SETSIZE; n++)
if ((FD_ISSET(n, &hardware->h_recvfds)) &&
(FD_ISSET(n, &rfds))) break;
- if (n == FD_SETSIZE) continue;
+ if (n == LLDPD_FD_SETSIZE) continue;
if ((buffer = (char *)malloc(
hardware->h_mtu)) == NULL) {
LLOG_WARN("failed to alloc reception buffer");