Don't use a hard-coded '32' for the select over the auth, acct,
authoraland <aland>
Wed, 6 Mar 2002 16:36:09 +0000 (16:36 +0000)
committeraland <aland>
Wed, 6 Mar 2002 16:36:09 +0000 (16:36 +0000)
and proxy FD's.  The modules are configured *before* these FD's
are opened, so there may be more than 32 FD's in use.

Instead, we have to dynamically figure out what the maximum FD
is from the set we're selecting over, and use that value.

Bug found by Cvetan Ivanov <zezo@spnet.net>

src/main/radiusd.c

index 7597e56..aff4190 100644 (file)
@@ -528,6 +528,7 @@ int main(int argc, char *argv[])
        int pid;
        int i;
        int fd = 0;
+       int max_fd;
        int status;
        int radius_port = 0;
        struct servent *svp;
@@ -945,18 +946,27 @@ int main(int argc, char *argv[])
                }
 
                FD_ZERO(&readfds);
-               if (authfd >= 0)
+               max_fd = 0;
+               if (authfd >= 0) {
                        FD_SET(authfd, &readfds);
-               if (acctfd >= 0)
+                       if (authfd > max_fd) max_fd = authfd;
+               }
+               if (acctfd >= 0) {
                        FD_SET(acctfd, &readfds);
-               if (proxyfd >= 0)
+                       if (acctfd > max_fd) max_fd = acctfd;
+               }
+               if (proxyfd >= 0) {
                        FD_SET(proxyfd, &readfds);
+                       if (proxyfd > max_fd) max_fd = proxyfd;
+               }
 #ifdef WITH_SNMP
-               if (rad_snmp.smux_fd >= 0)
+               if (rad_snmp.smux_fd >= 0) {
                        FD_SET(rad_snmp.smux_fd, &readfds);
+                       if (rad_snmp.smux_fd > max_fd) max_fd = rad_snmp.smux_fd;
+               }
 #endif
 
-               status = select(32, &readfds, NULL, NULL, tv);
+               status = select(max_fd, &readfds, NULL, NULL, tv);
                if (status == -1) {
                        /*
                         *  On interrupts, we clean up the