From: Kurt Zeilenga Date: Tue, 18 Aug 1998 18:19:49 +0000 (+0000) Subject: Changed FD_SETSIZE checks for consistency. Added checks where needed. X-Git-Tag: OPENLDAP_REL_ENG_1_0_0~32 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=f51765eead71ed92145e88a918f9c51532300de0;p=openldap Changed FD_SETSIZE checks for consistency. Added checks where needed. --- diff --git a/Make-common b/Make-common index 1869d320d9..a11976265c 100644 --- a/Make-common +++ b/Make-common @@ -45,9 +45,9 @@ RUNTIMEETCDIR?= $(ETCDIR) ## General compiler options ## ############################################################################# # Passed to every compile (cc or gcc). This is where you put -O or -g, etc. -EXTRACFLAGS=-O -g +#EXTRACFLAGS=-O -g #EXTRACFLAGS=-O -#EXTRACFLAGS=-g +EXTRACFLAGS=-g # Passed to every link (ld). Include -g here if you did in EXTRACFLAGS. EXTRALDFLAGS=-g @@ -142,8 +142,15 @@ SLAPD_BACKENDS= -DLDAP_LDBM # -DLDAP_SHELL -DLDAP_PASSWD LDBMBACKEND?=-DLDBM_USE_NDBM LDBMINCLUDE?= LDBMLIB?= -# -# if you want to use a non-default threads package change these lines +# if you want to use a non-default threads package change the defines below +# to one of: +# -DPOSIX_THREADS (draft 10 or standard) +# -DTHREAD_MIT_PTHREADS (draft 4) +# -DTHREAD_NEXT_CTHREADS +# -DTHREAD_DCE_PTHREADS +# -DTHREAD_SUNOS4_LWP +# -DTHREAD_SUNOS5_LWP +# and select the appropriate library. #THREADS?=-DNO_THREADS #THREADSLIB?= diff --git a/build/platforms/freebsd-gcc/Make-platform b/build/platforms/freebsd-gcc/Make-platform index 66a943256f..6df57c5be5 100644 --- a/build/platforms/freebsd-gcc/Make-platform +++ b/build/platforms/freebsd-gcc/Make-platform @@ -18,18 +18,12 @@ LDBMINCLUDE=-I/usr/include # package. Rather than resolve this globally, I have marked the # threading as "preeemptive", even though it is technically not. # -# As far as I have been able to determine, there are not buzz-loop -# based races in the LDAP code (at least not now that I've fixed -# the bogus FD_SETSIZE assumptions about the select(2) system call -# implementation being in any way related to getdtablesize(2) -- -# if it were, sys/types.h would define FD_SETSIZE in terms of the -# getdtablesize(2) call, and there would be no implicit limits). -# # This means that the implicit-yield threading is topologically # equivalent to preemptive threading. # THREADS= -D_THREAD_SAFE -DPOSIX_THREADS -DPTHREAD_PREEMPTIVE THREADSLIB= -pthread +#THREADSLIB= -lc_r # we need to link in the V3 library to get sigset() PLATFORMLIBS= -lcrypt diff --git a/clients/finger/main.c b/clients/finger/main.c index 64640543a4..77e076fdc7 100644 --- a/clients/finger/main.c +++ b/clients/finger/main.c @@ -172,20 +172,17 @@ static do_query() exit( 1 ); } -#ifdef FD_SETSIZE - /* - * It is invalid to use a set size in excess of the type - * scope, as defined for the fd_set in sys/types.h. This - * is true for any OS. - */ - tblsize = FD_SETSIZE; -#else /* !FD_SETSIZE*/ #ifdef USE_SYSCONF tblsize = sysconf( _SC_OPEN_MAX ); #else /* USE_SYSCONF */ tblsize = getdtablesize(); #endif /* USE_SYSCONF */ -#endif /* !FD_SETSIZE*/ + +#ifdef FD_SETSIZE + if (tblsize > FD_SETSIZE) { + tblsize = FD_SETSIZE; + } +#endif /* FD_SETSIZE*/ timeout.tv_sec = FINGER_TIMEOUT; timeout.tv_usec = 0; diff --git a/clients/gopher/detach.c b/clients/gopher/detach.c index f543cc3060..09997c1298 100644 --- a/clients/gopher/detach.c +++ b/clients/gopher/detach.c @@ -33,6 +33,13 @@ int debug; nbits = getdtablesize(); #endif /* USE_SYSCONF */ +#ifdef FD_SETSIZE + if (nbits > FD_SETSIZE) { + nbits = FD_SETSIZE; + } +#endif /* FD_SETSIZE*/ + + if ( debug == 0 || !(isatty( 1 )) ) { for ( i = 0; i < 5; i++ ) { switch ( fork() ) { diff --git a/clients/gopher/go500.c b/clients/gopher/go500.c index 484c39c556..0697904295 100644 --- a/clients/gopher/go500.c +++ b/clients/gopher/go500.c @@ -140,20 +140,18 @@ char **argv; } #endif -#ifdef FD_SETSIZE - /* - * It is invalid to use a set size in excess of the type - * scope, as defined for the fd_set in sys/types.h. This - * is true for any OS. - */ - dtblsize = FD_SETSIZE; -#else /* !FD_SETSIZE*/ #ifdef USE_SYSCONF dtblsize = sysconf( _SC_OPEN_MAX ); #else /* USE_SYSCONF */ dtblsize = getdtablesize(); #endif /* USE_SYSCONF */ -#endif /* !FD_SETSIZE*/ + +#ifdef FD_SETSIZE + if (dtblsize > FD_SETSIZE) { + dtblsize = FD_SETSIZE; + } +#endif /* FD_SETSIZE*/ + /* detach if stderr is redirected or no debugging */ if ( inetd == 0 ) diff --git a/clients/gopher/go500gw.c b/clients/gopher/go500gw.c index 01d8b0cbc4..16674d0e80 100644 --- a/clients/gopher/go500gw.c +++ b/clients/gopher/go500gw.c @@ -150,20 +150,19 @@ char **argv; } } -#ifdef FD_SETSIZE - /* - * It is invalid to use a set size in excess of the type - * scope, as defined for the fd_set in sys/types.h. This - * is true for any OS. - */ - dtblsize = FD_SETSIZE; -#else /* !FD_SETSIZE*/ #ifdef USE_SYSCONF dtblsize = sysconf( _SC_OPEN_MAX ); #else /* USE_SYSCONF */ dtblsize = getdtablesize(); #endif /* USE_SYSCONF */ -#endif /* !FD_SETSIZE*/ + +#ifdef FD_SETSIZE + if ( dtblsize > FD_SETSIZE ) { + dtblsize = FD_SETSIZE; + } +#endif /* FD_SETSIZE*/ + + #ifdef GO500GW_HOSTNAME strcpy( myhost, GO500GW_HOSTNAME ); diff --git a/contrib/whois++/command.c b/contrib/whois++/command.c index f9688b37e5..2a59e32d8b 100644 --- a/contrib/whois++/command.c +++ b/contrib/whois++/command.c @@ -50,16 +50,14 @@ char *token; int i, status, tablesize; if ( buffer == NULL ) { -#ifdef FD_SETSIZE - /* - * It is invalid to use a set size in excess of the type - * scope, as defined for the fd_set in sys/types.h. This - * is true for any OS. - */ - tablesize = FD_SETSIZE; -#else /* !FD_SETSIZE*/ tablesize = getdtablesize(); -#endif /* !FD_SETSIZE*/ + +#ifdef FD_SETSIZE + if ( tablesize > FD_SETSIZE ) { + tablesize = FD_SETSIZE; + } +#endif /* FD_SETSIZE */ + timeout.tv_sec = 60; timeout.tv_usec = 0; FD_ZERO( &readfds ); diff --git a/servers/ldapd/detach.c b/servers/ldapd/detach.c index ff435eea82..ca45fda1a0 100644 --- a/servers/ldapd/detach.c +++ b/servers/ldapd/detach.c @@ -39,6 +39,12 @@ detach() nbits = getdtablesize(); #endif /* USE_SYSCONF */ +#ifdef FD_SETSIZE + if( nbits > FD_SETSIZE ) { + nbits = FD_SETSIZE; + } +#endif /* FD_SETSIZE */ + #ifdef LDAP_DEBUG if ( ldap_debug == 0 ) { #endif diff --git a/servers/ldapd/main.c b/servers/ldapd/main.c index 9edd4b532e..1be869fbc6 100644 --- a/servers/ldapd/main.c +++ b/servers/ldapd/main.c @@ -241,6 +241,12 @@ char **argv; dtblsize = getdtablesize(); #endif /* USE_SYSCONF */ +#ifdef FD_SETSIZE + if( dtblsize > FD_SETSIZE ) { + dtblsize = FD_SETSIZE; + } +#endif /* FD_SETSIZE */ + #ifndef NOSETPROCTITLE /* for setproctitle */ Argv = argv; diff --git a/servers/slapd/daemon.c b/servers/slapd/daemon.c index c88ab7ecc9..5044456cb7 100644 --- a/servers/slapd/daemon.c +++ b/servers/slapd/daemon.c @@ -89,7 +89,7 @@ slapd_daemon( if(dtblsize > FD_SETSIZE) { dtblsize = FD_SETSIZE; } -#endif /* !FD_SETSIZE*/ +#endif /* !FD_SETSIZE */ c = (Connection *) ch_calloc( 1, dtblsize * sizeof(Connection) ); diff --git a/servers/slapd/detach.c b/servers/slapd/detach.c index 7b3fdab57a..4b77122347 100644 --- a/servers/slapd/detach.c +++ b/servers/slapd/detach.c @@ -39,6 +39,12 @@ detach() nbits = getdtablesize(); #endif /* USE_SYSCONF */ +#ifdef FD_SETSIZE + if ( nbits > FD_SETSIZE ) { + nbits = FD_SETSIZE; + } +#endif /* FD_SETSIZE */ + #ifdef LDAP_DEBUG if ( ldap_debug == 0 ) { #endif diff --git a/servers/slurpd/detach.c b/servers/slurpd/detach.c index 7b3fdab57a..4b77122347 100644 --- a/servers/slurpd/detach.c +++ b/servers/slurpd/detach.c @@ -39,6 +39,12 @@ detach() nbits = getdtablesize(); #endif /* USE_SYSCONF */ +#ifdef FD_SETSIZE + if ( nbits > FD_SETSIZE ) { + nbits = FD_SETSIZE; + } +#endif /* FD_SETSIZE */ + #ifdef LDAP_DEBUG if ( ldap_debug == 0 ) { #endif