The Samba-Bugzilla – Attachment 796 Details for
Bug 2050
sys_select() used with a fixed first argument
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Fix wrepeld sys_select() call; ensure to count maxfd in smbd/server.c correct; use static int for maxfd in nmbd
select-maxfd.diff (text/plain), 4.75 KB, created by
Lars Müller
on 2004-11-19 05:12:13 UTC
(
hide
)
Description:
Fix wrepeld sys_select() call; ensure to count maxfd in smbd/server.c correct; use static int for maxfd in nmbd
Filename:
MIME Type:
Creator:
Lars Müller
Created:
2004-11-19 05:12:13 UTC
Size:
4.75 KB
patch
obsolete
>Index: source/smbd/server.c >=================================================================== >--- source/smbd/server.c (revision 3870) >+++ source/smbd/server.c (working copy) >@@ -186,7 +186,7 @@ > int fd_listenset[FD_SETSIZE]; > fd_set listen_set; > int s; >- int max_fd = 0; >+ int maxfd = 0; > int i; > char *ports; > >@@ -249,9 +249,6 @@ > if(s == -1) > return False; > >- if (max_fd < s) >- max_fd = s; >- > /* ready to listen */ > set_socket_options(s,"SO_KEEPALIVE"); > set_socket_options(s,user_socket_options); >@@ -265,6 +262,7 @@ > return False; > } > FD_SET(s,&listen_set); >+ maxfd = MAX( maxfd, s); > > num_sockets++; > if (num_sockets >= FD_SETSIZE) { >@@ -307,6 +305,7 @@ > > fd_listenset[num_sockets] = s; > FD_SET(s,&listen_set); >+ maxfd = MAX( maxfd, s); > > num_sockets++; > >@@ -341,7 +340,7 @@ > memcpy((char *)&lfds, (char *)&listen_set, > sizeof(listen_set)); > >- num = sys_select(max_fd+1,&lfds,NULL,NULL,NULL); >+ num = sys_select(maxfd+1,&lfds,NULL,NULL,NULL); > > if (num == -1 && errno == EINTR) { > if (got_sig_term) { >Index: source/nmbd/nmbd_packets.c >=================================================================== >--- source/nmbd/nmbd_packets.c (revision 3870) >+++ source/nmbd/nmbd_packets.c (working copy) >@@ -1635,16 +1635,6 @@ > } > > /**************************************************************************** >- 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. > ***************************************************************************/ >@@ -1682,25 +1672,25 @@ > /* Add in the broadcast socket on 137. */ > FD_SET(ClientNMB,pset); > sock_array[num++] = ClientNMB; >- check_set_maxfd( maxfd, ClientNMB); >+ *maxfd = MAX( *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); >+ *maxfd = MAX( *maxfd, subrec->nmb_sock); > } > > /* Add in the broadcast socket on 138. */ > FD_SET(ClientDGRAM,pset); > sock_array[num++] = ClientDGRAM; >- check_set_maxfd( maxfd, ClientDGRAM); >+ *maxfd = MAX( *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); >+ *maxfd = ( *maxfd, subrec->dgram_sock); > } > > *listen_number = (count*2) + 2; >@@ -1725,7 +1715,7 @@ > static int listen_number = 0; > static int *sock_array = NULL; > int i; >- int maxfd = 0; >+ static int maxfd = 0; > > fd_set fds; > int selrtn; >@@ -1748,7 +1738,7 @@ > dns_fd = asyncdns_fd(); > if (dns_fd != -1) { > FD_SET(dns_fd, &fds); >- check_set_maxfd( &maxfd, dns_fd); >+ maxfd = MAX( maxfd, dns_fd); > } > #endif > >Index: source/wrepld/server.c >=================================================================== >--- source/wrepld/server.c (revision 3870) >+++ source/wrepld/server.c (working copy) >@@ -164,7 +164,7 @@ > plus the broadcast sockets. > ***************************************************************************/ > >-static BOOL create_listen_fdset(void) >+static BOOL create_listen_fdset( int *maxfd) > { > int i; > int num_interfaces = iface_count(); >@@ -221,6 +221,7 @@ > } > add_fd_to_sock_array(s); > FD_SET(s, listen_set); >+ *maxfd = MAX( *maxfd, s); > } > } else { > /* Just bind to 0.0.0.0 - accept connections from anywhere. */ >@@ -243,6 +244,7 @@ > > add_fd_to_sock_array(s); > FD_SET(s, listen_set); >+ *maxfd = MAX( *maxfd, s); > } > > return True; >@@ -346,10 +348,11 @@ > int num_interfaces = iface_count(); > fd_set fds; > int i, num, s, new_s; >+ static int maxfd = 0; > struct timeval timeout; > > if(listen_set == NULL) { >- if(!create_listen_fdset()) { >+ if(!create_listen_fdset( &maxfd)) { > DEBUG(0,("listen_for_packets: Fatal error. unable to create listen set. Exiting.\n")); > return True; > } >@@ -364,7 +367,7 @@ > > BlockSignals(False, SIGTERM); > >- num = sys_select(FD_SETSIZE, &fds, NULL, NULL, &timeout); >+ num = sys_select(maxfd+1, &fds, NULL, NULL, &timeout); > > /* We can only take signals when we are in the select - block them again here. */ > >@@ -397,6 +400,7 @@ > set_socket_options(new_s, user_socket_options); > FD_SET(new_s, listen_set); > add_fd_to_sock_array(new_s); >+ maxfd = MAX( maxfd, new_s); > } > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 2050
:
781
|
795
| 796