Skip to content
Snippets Groups Projects
Commit f51765ee authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

Changed FD_SETSIZE checks for consistency. Added checks where needed.

parent dfeabf52
No related branches found
No related tags found
No related merge requests found
......@@ -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?=
......
......@@ -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
......
......@@ -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;
......
......@@ -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() ) {
......
......@@ -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 )
......
......@@ -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 );
......
......@@ -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 );
......
......@@ -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
......
......@@ -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;
......
......@@ -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) );
......
......@@ -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
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment