# if you want things to run in a different directory from where they
# are installed, set this accordingly (this path gets compiled into a
# few binaries). otherwise, leave it alone.
-RUNTIMEETCDIR= $(ETCDIR)
+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
+#EXTRACFLAGS=-O
+#EXTRACFLAGS=-g
# Passed to every link (ld). Include -g here if you did in EXTRACFLAGS.
EXTRALDFLAGS=-g
# You will also need to edit the include and lib strings appropriately.
#
# berkeley db btree package
-LDBMBACKEND=-DLDBM_USE_DBBTREE
-LDBMINCLUDE=-I/usr/include
#LDBMLIB=-ldb
+#LDBMBACKEND?=-DLDBM_USE_DBBTREE
+#LDBMINCLUDE?=-I/usr/local/db/include
+#LDBMLIB?=-ldb
# berkeley db hash package
-#LDBMBACKEND=-DLDBM_USE_DBHASH
-#LDBMINCLUDE=-I/usr/local/db/include
-#LDBMLIB=-ldb
+#LDBMBACKEND?=-DLDBM_USE_DBHASH
+#LDBMINCLUDE?=-I/usr/local/db/include
+#LDBMLIB?=-ldb
# gnu dbm (gdbm)
-#LDBMBACKEND=-DLDBM_USE_GDBM
-#LDBMINCLUDE=-I/usr/local/gdbm/include
-#LDBMLIB=-lgdbm
+#LDBMBACKEND?=-DLDBM_USE_GDBM
+#LDBMINCLUDE?=-I/usr/local/gdbm/include
+#LDBMLIB?=-lgdbm
# standard unix ndbm
-#LDBMBACKEND=-DLDBM_USE_NDBM
+LDBMBACKEND?=-DLDBM_USE_NDBM
+LDBMINCLUDE?=
+LDBMLIB?=
#
# if you want to use a non-default threads package change these lines
-#THREADS=-DPOSIX_THREADS
-#THREADSLIB= -pthread
+#THREADS?=-DNO_THREADS
+#THREADSLIB?=
#############################################################################
## The following options are used by the xax500 client. If you haven't ##
#
# add any platform-specific overrides below here
#
+PREFIX?=/usr/local
+INSTROOT=${PREFIX}
+ETCDIR= $(INSTROOT)/etc/ldap
+EXTRACFLAGS=-O -DLDAP_DEBUG
+LDBMBACKEND=-DLDBM_USE_DBBTREE
+LDBMINCLUDE=-I/usr/include
+#
+# LDAP has a problem with the idea of implicit vs. explicit yields
+# in call conversion threading packages, like the MIT pthreads
+# 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
+
+# we need to link in the V3 library to get sigset()
+PLATFORMLIBS= -lcrypt
#
# -------------------------------------------------------------------------
# you will probably not need to edit anything below this point
# -------------------------------------------------------------------------
-CC = cc
+CC = gcc
PLATFORMCFLAGS= -Dfreebsd
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*/
timeout.tv_sec = FINGER_TIMEOUT;
timeout.tv_usec = 0;
}
#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*/
/* detach if stderr is redirected or no debugging */
if ( inetd == 0 )
}
}
+#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 GO500GW_HOSTNAME
strcpy( myhost, GO500GW_HOSTNAME );
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*/
timeout.tv_sec = 60;
timeout.tv_usec = 0;
FD_ZERO( &readfds );
#include <stdarg.h>
#include "macos.h"
#else /* MACOS */
-#if defined(NeXT) || defined(VMS)
+
+#if defined(NeXT) || defined(VMS) || defined(__FreeBSD__)
#include <stdlib.h>
-#else /* next || vms */
-#ifndef __FreeBSD__
+#else /* next || vms || freebsd */
#include <malloc.h>
-#endif
-#endif /* next || vms */
+#endif /* next || vms || freebsd */
#if defined(BC31) || defined(_WIN32)
#include <stdarg.h>
#else /* BC31 || _WIN32 */
#include <stdarg.h>
#include "macos.h"
#else /* MACOS */
-#if defined(NeXT) || defined(VMS)
+#if defined(NeXT) || defined(VMS) || defined(__FreeBSD__)
#include <stdlib.h>
-#else /* next || vms */
-#ifndef __FreeBSD__
+#else /* next || vms || freebsd */
#include <malloc.h>
-#endif
-#endif /* next || vms */
-#if defined( BC31 ) || defined( _WIN32 )
+#endif /* next || vms || freebsd */
+#if defined( BC31 ) || defined( _WIN32 )
#include <stdarg.h>
#else /* BC31 || _WIN32 */
#include <varargs.h>
Debug( LDAP_DEBUG_TRACE, "do_ldap_select\n", 0, 0, 0 );
if ( tblsize == 0 ) {
+#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*/
}
sip = (struct selectinfo *)ld->ld_selectinfo;
*result = l;
ld->ld_errno = LDAP_SUCCESS;
#ifdef LDAP_WORLD_P16
- /* inclusion of this patch causes searchs to hang on
- multiple platforms */
+ /*
+ * XXX questionable fix; see text for [P16] on
+ * http://www.critical-angle.com/ldapworld/patch/
+ *
+ * inclusion of this patch causes searchs to hang on
+ * multiple platforms
+ */
return( l->lm_msgtype );
-#else
+#else /* LDAP_WORLD_P16 */
return( tag );
-#endif
+#endif /* !LDAP_WORLD_P16 */
}
return( -2 ); /* continue looking */
static int tblsize;
if ( tblsize == 0 ) {
+#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*/
}
FD_ZERO( &readfds );
Debug( LDAP_DEBUG_TRACE, "do_ldap_select\n", 0, 0, 0 );
if ( tblsize == 0 ) {
+#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
#endif /* USE_SYSCONF */
+#endif /* !FD_SETSIZE*/
}
sip = (struct selectinfo *)ld->ld_selectinfo;
pthread_attr_init( &attr );
pthread_attr_setdetachstate( &attr, PTHREAD_CREATE_DETACHED );
+#ifdef PTHREAD_MUTEX_INITIALIZER
+ /*
+ * This is a draft 10 or standard pthreads implementation
+ */
+ if ( pthread_create( &arg->co_op->o_tid, attr,
+ (void *) connection_operation, (void *) arg ) != 0 ) {
+ Debug( LDAP_DEBUG_ANY, "pthread_create failed\n", 0, 0, 0 );
+ } else {
+ pthread_mutex_lock( &active_threads_mutex );
+ active_threads++;
+ pthread_mutex_unlock( &active_threads_mutex );
+ }
+#else /* !PTHREAD_MUTEX_INITIALIZER*/
+ /*
+ * This is a draft 4 or earlier pthreads implementation
+ */
if ( pthread_create( &arg->co_op->o_tid, &attr,
(void *) connection_operation, (void *) arg ) != 0 ) {
Debug( LDAP_DEBUG_ANY, "pthread_create failed\n", 0, 0, 0 );
active_threads++;
pthread_mutex_unlock( &active_threads_mutex );
}
+#endif /* !PTHREAD_MUTEX_INITIALIZER*/
pthread_attr_destroy( &attr );
}
int on = 1;
#ifdef USE_SYSCONF
- dtblsize = sysconf( _SC_OPEN_MAX );
+ dtblsize = sysconf( _SC_OPEN_MAX );
#else /* USE_SYSCONF */
- dtblsize = getdtablesize();
+ dtblsize = getdtablesize();
#endif /* USE_SYSCONF */
/*
* Add greg@greg.rim.or.jp
*/
+#ifdef FD_SETSIZE
if(dtblsize > FD_SETSIZE) {
dtblsize = FD_SETSIZE;
}
+#endif /* !FD_SETSIZE*/
+
c = (Connection *) ch_calloc( 1, dtblsize * sizeof(Connection) );
for ( i = 0; i < dtblsize; i++ ) {
#endif
pthread_mutex_unlock( &active_threads_mutex );
- switch ( select( dtblsize, &readfds, &writefds, 0, tvp ) ) {
+ switch ( i = select( dtblsize, &readfds, &writefds, 0, tvp ) ) {
case -1: /* failure - try again */
Debug( LDAP_DEBUG_CONNS,
"select failed errno %d (%s)\n",
continue;
default: /* something happened - deal with it */
- Debug( LDAP_DEBUG_CONNS, "select activity\n", 0, 0, 0 );
+ Debug( LDAP_DEBUG_CONNS, "select activity on %d descriptors\n", i, 0, 0 );
; /* FALL */
}
pthread_mutex_lock( ¤ttime_mutex );
extern char Versionstr[];
+
/*
* read-only global variables or variables only written by the listener
* thread (after they are initialized) - no need to protect them with a mutex.
pthread_attr_init( &attr );
pthread_attr_setdetachstate( &attr, PTHREAD_CREATE_DETACHED );
+#ifdef PTHREAD_MUTEX_INITIALIZER
+ /*
+ * This is a draft 10 or standard pthreads implementation
+ */
+ if ( pthread_create( &listener_tid, attr, (void *) slapd_daemon,
+ (void *) port ) != 0 ) {
+ Debug( LDAP_DEBUG_ANY,
+ "listener pthread_create failed\n", 0, 0, 0 );
+ exit( 1 );
+ }
+#else /* !PTHREAD_MUTEX_INITIALIZER */
+ /*
+ * This is a draft 4 or earlier pthreads implementation
+ */
if ( pthread_create( &listener_tid, &attr, (void *) slapd_daemon,
(void *) port ) != 0 ) {
Debug( LDAP_DEBUG_ANY,
"listener pthread_create failed\n", 0, 0, 0 );
exit( 1 );
}
+#endif /* !PTHREAD_MUTEX_INITIALIZER */
pthread_attr_destroy( &attr );
pthread_join( listener_tid, (void *) &status );
pthread_exit( 0 );
#ifndef SYSERRLIST_IN_STDIO
extern char *sys_errlist[];
-#endif /* SYSERRLIST_IN_STDIO
+#endif /* SYSERRLIST_IN_STDIO */
/* Forward references */
static Rh *get_repl_hosts( char *, int *, char ** );
pthread_attr_init( &attr );
pthread_attr_setdetachstate( &attr, PTHREAD_CREATE_DETACHED );
+#ifdef PTHREAD_MUTEX_INITIALIZER
+ /*
+ * This is a draft 10 or standard pthreads implementation
+ */
+ if ( pthread_create( &(ri->ri_tid), attr, (void *) replicate,
+ (void *) ri ) != 0 ) {
+ Debug( LDAP_DEBUG_ANY, "replica \"%s:%d\" pthread_create failed\n",
+ ri->ri_hostname, ri->ri_port, 0 );
+ pthread_attr_destroy( &attr );
+ return -1;
+ }
+#else /* !PTHREAD_MUTEX_INITIALIZER */
+ /*
+ * This is a draft 4 or earlier pthreads implementation
+ */
if ( pthread_create( &(ri->ri_tid), &attr, (void *) replicate,
(void *) ri ) != 0 ) {
Debug( LDAP_DEBUG_ANY, "replica \"%s:%d\" pthread_create failed\n",
pthread_attr_destroy( &attr );
return -1;
}
+#endif /* !PTHREAD_MUTEX_INITIALIZER */
pthread_attr_destroy( &attr );
return 0;
}
extern void Re_dump();
#endif /* NEEDPROTOS */
-#ifndef SYSERRLIST_IN_STDIO
+#ifndef SYSERRLIST_IN_STDIO
extern char *sys_errlist[];
-#endif /* SYSERRLIST_IN_STDIO
+#endif /* SYSERRLIST_IN_STDIO */
/*
* Lock the replication queue.