Commit fa2da63c authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

Merge from LAMBERT branch

parent 401bd749
......@@ -39,14 +39,15 @@ BINDIR= $(INSTROOT)/bin
# 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
......@@ -125,23 +126,26 @@ SLAPD_BACKENDS= -DLDAP_LDBM # -DLDAP_SHELL -DLDAP_PASSWD
# 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 ##
......
......@@ -6,12 +6,39 @@
#
# 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
......@@ -172,11 +172,20 @@ 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*/
timeout.tv_sec = FINGER_TIMEOUT;
timeout.tv_usec = 0;
......
......@@ -140,11 +140,20 @@ 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*/
/* detach if stderr is redirected or no debugging */
if ( inetd == 0 )
......
......@@ -150,11 +150,20 @@ 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 GO500GW_HOSTNAME
strcpy( myhost, GO500GW_HOSTNAME );
......
......@@ -50,7 +50,16 @@ 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*/
timeout.tv_sec = 60;
timeout.tv_usec = 0;
FD_ZERO( &readfds );
......
......@@ -17,13 +17,12 @@
#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 */
......
......@@ -17,14 +17,12 @@
#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>
......
......@@ -314,11 +314,20 @@ do_ldap_select( LDAP *ld, struct timeval *timeout )
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;
......
......@@ -543,12 +543,17 @@ lr->lr_res_matched ? lr->lr_res_matched : "" );
*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 */
......@@ -633,11 +638,20 @@ ldap_select1( LDAP *ld, struct timeval *timeout )
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 );
......
......@@ -446,6 +446,14 @@ do_ldap_select( LDAP *ld, struct timeval *timeout )
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 */
......@@ -455,6 +463,7 @@ do_ldap_select( LDAP *ld, struct timeval *timeout )
tblsize = getdtablesize();
#endif
#endif /* USE_SYSCONF */
#endif /* !FD_SETSIZE*/
}
sip = (struct selectinfo *)ld->ld_selectinfo;
......
......@@ -203,6 +203,22 @@ connection_activity(
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 );
......@@ -211,5 +227,6 @@ connection_activity(
active_threads++;
pthread_mutex_unlock( &active_threads_mutex );
}
#endif /* !PTHREAD_MUTEX_INITIALIZER*/
pthread_attr_destroy( &attr );
}
......@@ -78,16 +78,19 @@ slapd_daemon(
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++ ) {
......@@ -222,7 +225,7 @@ slapd_daemon(
#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",
......@@ -237,7 +240,7 @@ slapd_daemon(
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( &currenttime_mutex );
......
......@@ -15,6 +15,7 @@ extern int lber_debug;
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.
......@@ -184,12 +185,27 @@ main( argc, argv )
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 );
......
......@@ -33,7 +33,7 @@ extern void ch_free( char *p );
#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 ** );
......
......@@ -59,6 +59,21 @@ start_replica_thread(
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",
......@@ -66,6 +81,7 @@ start_replica_thread(
pthread_attr_destroy( &attr );
return -1;
}
#endif /* !PTHREAD_MUTEX_INITIALIZER */
pthread_attr_destroy( &attr );
return 0;
}
......@@ -44,9 +44,9 @@ extern void Re_dump( Re *re );
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.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment