]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/main.c
complete this round of constification
[openldap] / servers / slapd / main.c
index 0cbdab394aaed6cd4bf19ff9db028dcc61ba8a9a..53398e99933097c65ec6cb17fed3d6352a20a40a 100644 (file)
@@ -1,3 +1,7 @@
+/*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
 #include "portable.h"
 
 #include <stdio.h>
@@ -101,7 +105,7 @@ usage( char *name )
 #if defined(HAVE_SETUID) && defined(HAVE_SETGID)
                "\t-g group\tGroup (id or name) to ran as\n"
 #endif
-               "\t-h URLs\tList of URLs to serve"
+               "\t-h URLs\tList of URLs to serve\n"
 #ifdef LOG_LOCAL4
                "\t-l sysloguser\tSyslog User (default: LOCAL4)\n"
 #endif
@@ -155,6 +159,13 @@ int main( int argc, char **argv )
        int tls_port = 0;
 #endif
 
+#ifdef CSRIMALLOC
+       FILE *leakfile;
+       if( ( leakfile = fopen( "slapd.leak", "w" )) == NULL ) {
+               leakfile = stderr;
+       }
+#endif
+
        g_argc = argc;
        g_argv = argv;
 
@@ -162,7 +173,6 @@ int main( int argc, char **argv )
        {
                int *i;
                char *newConfigFile;
-               ldap_debug = 0xffff;
                if ( is_NT_Service ) CommenceStartupProcessing( NTservice, slap_set_shutdown );
                i = (int*)getRegParam( NULL, "Port" );
                if ( i != NULL )
@@ -194,7 +204,7 @@ int main( int argc, char **argv )
 #endif
 
        while ( (i = getopt( argc, argv,
-                            "d:f:h:p:s:u"
+                            "d:f:h:p:s:"
 #ifdef LOG_LOCAL4
                             "l:"
 #endif
@@ -273,13 +283,13 @@ int main( int argc, char **argv )
                case 'c':       /* do connectionless (udp) */
                        /* udp = 1; */
                        fprintf( stderr, "connectionless support not supported");
-                       exit( -1 );
+                       exit( EXIT_FAILURE );
                        break;
 #endif
 
 #ifdef SLAPD_BDB2
                case 't':  /* timed server */
-                       serverMode = SLAP_TIMEDSERVER_MODE;
+                       serverMode |= SLAP_TIMED_MODE;
                        break;
 #endif
 
@@ -381,7 +391,11 @@ int main( int argc, char **argv )
 #endif
 #endif /* HAVE_WINSOCK */
 
-       if ( slap_startup(-1)  != 0 ) {
+#ifdef CSRIMALLOC
+       mal_leaktrace(1);
+#endif
+
+       if ( slap_startup( NULL )  != 0 ) {
                rc = 1;
                SERVICE_EXIT( ERROR_SERVICE_SPECIFIC_ERROR, 20 );
                goto shutdown;
@@ -424,7 +438,8 @@ int main( int argc, char **argv )
 
 shutdown:
        /* remember an error during shutdown */
-       rc |= slap_shutdown(-1);
+       rc |= slap_shutdown( NULL );
+
 destroy:
        /* remember an error during destroy */
        rc |= slap_destroy();
@@ -443,6 +458,10 @@ stop:
     closelog();
        slapd_daemon_destroy();
 
+#ifdef CSRIMALLOC
+       mal_dumpleaktrace( leakfile );
+#endif
+
        MAIN_RETURN(rc);
 }