diff options
author | Jeremy Allison <jra@samba.org> | 2004-11-18 22:11:20 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 10:53:22 -0500 |
commit | 4a505a2860c08c8223b44507e212a4ce5e433bea (patch) | |
tree | 52f04aab90af828c3e27662660aedfc7fa7c5ccc /source3/nmbd | |
parent | d956222083768df5f6d9f6c45f39d70232b7da8f (diff) | |
download | samba-4a505a2860c08c8223b44507e212a4ce5e433bea.tar.gz samba-4a505a2860c08c8223b44507e212a4ce5e433bea.tar.bz2 samba-4a505a2860c08c8223b44507e212a4ce5e433bea.zip |
r3864: Fix from Lars Müller <lmuelle@suse.de> for bug #2050.
Make nmbd use maxfd+1 in select also.
Jeremy.
(This used to be commit e3ca22b80dc1c22f0e5c829d11724c79e317641f)
Diffstat (limited to 'source3/nmbd')
-rw-r--r-- | source3/nmbd/nmbd_packets.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/source3/nmbd/nmbd_packets.c b/source3/nmbd/nmbd_packets.c index 96de4911dc..9dd2d05e14 100644 --- a/source3/nmbd/nmbd_packets.c +++ b/source3/nmbd/nmbd_packets.c @@ -1635,11 +1635,21 @@ on subnet %s\n", rrec->response_id, inet_ntoa(rrec->packet->ip), subrec->subnet_ } /**************************************************************************** + Check and if required set the highest fd. +***************************************************************************/ + +void check_set_maxfd( int *maxfd, int fd) +{ + if ( *maxfd < fd ) + *maxfd = fd; +} + +/**************************************************************************** Create an fd_set containing all the sockets in the subnet structures, plus the broadcast sockets. ***************************************************************************/ -static BOOL create_listen_fdset(fd_set **ppset, int **psock_array, int *listen_number) +static BOOL create_listen_fdset(fd_set **ppset, int **psock_array, int *listen_number, int *maxfd) { int *sock_array = NULL; struct subnet_record *subrec = NULL; @@ -1672,21 +1682,25 @@ only use %d.\n", (count*2) + 2, FD_SETSIZE)); /* Add in the broadcast socket on 137. */ FD_SET(ClientNMB,pset); sock_array[num++] = ClientNMB; + check_set_maxfd( maxfd, ClientNMB); /* Add in the 137 sockets on all the interfaces. */ for (subrec = FIRST_SUBNET; subrec; subrec = NEXT_SUBNET_EXCLUDING_UNICAST(subrec)) { FD_SET(subrec->nmb_sock,pset); sock_array[num++] = subrec->nmb_sock; + check_set_maxfd( maxfd, subrec->nmb_sock); } /* Add in the broadcast socket on 138. */ FD_SET(ClientDGRAM,pset); sock_array[num++] = ClientDGRAM; + check_set_maxfd( maxfd, ClientDGRAM); /* Add in the 138 sockets on all the interfaces. */ for (subrec = FIRST_SUBNET; subrec; subrec = NEXT_SUBNET_EXCLUDING_UNICAST(subrec)) { FD_SET(subrec->dgram_sock,pset); sock_array[num++] = subrec->dgram_sock; + check_set_maxfd( maxfd, subrec->dgram_sock); } *listen_number = (count*2) + 2; @@ -1711,6 +1725,7 @@ BOOL listen_for_packets(BOOL run_election) static int listen_number = 0; static int *sock_array = NULL; int i; + int maxfd = 0; fd_set fds; int selrtn; @@ -1720,7 +1735,7 @@ BOOL listen_for_packets(BOOL run_election) #endif if(listen_set == NULL || rescan_listen_set) { - if(create_listen_fdset(&listen_set, &sock_array, &listen_number)) { + if(create_listen_fdset(&listen_set, &sock_array, &listen_number, &maxfd)) { DEBUG(0,("listen_for_packets: Fatal error. unable to create listen set. Exiting.\n")); return True; } @@ -1733,6 +1748,7 @@ BOOL listen_for_packets(BOOL run_election) dns_fd = asyncdns_fd(); if (dns_fd != -1) { FD_SET(dns_fd, &fds); + check_set_maxfd( &maxfd, dns_fd); } #endif @@ -1750,7 +1766,7 @@ BOOL listen_for_packets(BOOL run_election) BlockSignals(False, SIGTERM); - selrtn = sys_select(FD_SETSIZE,&fds,NULL,NULL,&timeout); + selrtn = sys_select(maxfd+1,&fds,NULL,NULL,&timeout); /* We can only take signals when we are in the select - block them again here. */ |