X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fmain.c;h=106617fa06f4924021837f7c4980f52153a1cf35;hb=ceb1c5ce1c22a1e062cf724d222b126751e2906a;hp=ec3b4a9b93e3ac01df30993e086edbc2aaea653d;hpb=0c3899577f5000e25cfa2248b8dcc3aec5af2b56;p=openldap diff --git a/servers/slapd/main.c b/servers/slapd/main.c index ec3b4a9b93..106617fa06 100644 --- a/servers/slapd/main.c +++ b/servers/slapd/main.c @@ -5,16 +5,12 @@ #include #include #include +#include -#include "slap.h" #include "ldapconfig.h" +#include "slap.h" #include "lutil.h" /* Get lutil_detach() */ -extern void slapd_daemon(); -extern int lber_debug; - -extern char Versionstr[]; - /* * read-only global variables or variables only written by the listener @@ -43,6 +39,9 @@ pthread_mutex_t currenttime_mutex; int active_threads; pthread_mutex_t active_threads_mutex; pthread_mutex_t new_conn_mutex; +#ifdef SLAPD_CRYPT +pthread_mutex_t crypt_mutex; +#endif long ops_initiated; long ops_completed; int num_conns; @@ -58,16 +57,13 @@ pthread_mutex_t entry2str_mutex; pthread_mutex_t replog_mutex; static void -usage( name ) - char *name; +usage( char *name ) { fprintf( stderr, "usage: %s [-d ?|debuglevel] [-f configfile] [-p portnumber] [-s sysloglevel]\n", name ); } int -main( argc, argv ) - int argc; - char **argv; +main( int argc, char **argv ) { int i; int inetd = 0; @@ -75,7 +71,6 @@ main( argc, argv ) char *myname; Backend *be = NULL; FILE *fp = NULL; - extern char *optarg; configfile = SLAPD_DEFAULT_CONFIGFILE; port = LDAP_PORT; @@ -128,7 +123,7 @@ main( argc, argv ) #endif case 'f': /* read config file */ - configfile = strdup( optarg ); + configfile = ch_strdup( optarg ); break; case 'i': /* run from inetd */ @@ -156,9 +151,9 @@ main( argc, argv ) Debug( LDAP_DEBUG_TRACE, "%s", Versionstr, 0, 0 ); if ( (myname = strrchr( argv[0], '/' )) == NULL ) { - myname = strdup( argv[0] ); + myname = ch_strdup( argv[0] ); } else { - myname = strdup( myname + 1 ); + myname = ch_strdup( myname + 1 ); } if ( ! inetd ) { @@ -180,37 +175,25 @@ main( argc, argv ) read_config( configfile, &be, fp ); if ( ! inetd ) { - pthread_attr_t attr; int status; time( &starttime ); - pthread_attr_init( &attr ); - pthread_attr_setdetachstate( &attr, PTHREAD_CREATE_DETACHED ); - -#if !defined(HAVE_PTHREADS_D4) && !defined(HAVE_DCE) - /* POSIX_THREADS or compatible - * This is a draft 10 or standard pthreads implementation - */ - if ( pthread_create( &listener_tid, &attr, slapd_daemon, - (void *) port ) != 0 ) { - Debug( LDAP_DEBUG_ANY, - "listener pthread_create failed\n", 0, 0, 0 ); - exit( 1 ); - } -#else /* draft4 */ - /* - * This is a draft 4 or earlier pthreads implementation - */ - if ( pthread_create( &listener_tid, attr, slapd_daemon, + + if ( pthread_create( &listener_tid, NULL, slapd_daemon, (void *) port ) != 0 ) { Debug( LDAP_DEBUG_ANY, "listener pthread_create failed\n", 0, 0, 0 ); exit( 1 ); } -#endif /* !draft4 */ - pthread_attr_destroy( &attr ); + +#ifdef HAVE_PHREADS_FINAL + pthread_join( listener_tid, (void *) NULL ); +#else pthread_join( listener_tid, (void *) &status ); - pthread_exit( 0 ); +#endif + + return 0; + } else { Connection c; Operation *o; @@ -251,7 +234,7 @@ main( argc, argv ) inet_ntoa( from.sin_addr ), 0 ); c.c_addr = inet_ntoa( from.sin_addr ); - c.c_domain = strdup( hp == NULL ? "" : hp->h_name ); + c.c_domain = ch_strdup( hp == NULL ? "" : hp->h_name ); } else { Debug( LDAP_DEBUG_ARGS, "connection from unknown\n", 0, 0, 0 ); @@ -268,7 +251,8 @@ main( argc, argv ) != LDAP_TAG_MSGID ) { /* log and send error */ Debug( LDAP_DEBUG_ANY, - "ber_get_int returns 0x%x\n", tag, 0, 0 ); + "ber_get_int returns 0x%lx\n", tag, 0, 0 ); + ber_free( &ber, 1 ); return 1; } @@ -276,7 +260,7 @@ main( argc, argv ) == LBER_ERROR ) { /* log, close and send error */ Debug( LDAP_DEBUG_ANY, - "ber_peek_tag returns 0x%x\n", tag, 0, 0 ); + "ber_peek_tag returns 0x%lx\n", tag, 0, 0 ); ber_free( &ber, 1 ); close( c.c_sb.sb_sd ); c.c_sb.sb_sd = -1;