]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/main.c
Fixup bdb_entry_release now that entry_decode uses two memory blocks
[openldap] / servers / slapd / main.c
index ebf130a0be1e142397c4dfa58a99a6a57522b3b1..0411a8d35fe06b4ec25c425dbada49247042efe1 100644 (file)
 #include <ac/wait.h>
 #include <ac/errno.h>
 
+#include "ldap_pvt.h"
+
 #include "slap.h"
 #include "lutil.h"
+#include "ldif.h"
 
 #ifdef LDAP_SIGCHLD
 static RETSIGTYPE wait4child( int sig );
@@ -29,7 +32,8 @@ struct sockaddr_in    bind_addr;
 /* in nt_main.c */
 LDAP_LUTIL_V(SERVICE_STATUS)           SLAPDServiceStatus;
 LDAP_LUTIL_V(SERVICE_STATUS_HANDLE)    hSLAPDServiceStatus;
-extern ldap_pvt_thread_cond_t  started_event,          stopped_event;
+/* externs are frowned upon, but so is NT :-) */
+extern ldap_pvt_thread_cond_t  started_event, stopped_event;
 extern int       is_NT_Service;
 
 void CommenceStartupProcessing( LPCTSTR serverName,
@@ -126,7 +130,7 @@ int main( int argc, char **argv )
 #endif
 {
        int             i, no_detach = 0;
-       int             rc;
+       int             rc = 1;
        char *urls = NULL;
 #if defined(HAVE_SETUID) && defined(HAVE_SETGID)
        char *username = NULL;
@@ -399,8 +403,30 @@ int main( int argc, char **argv )
 
 #ifdef HAVE_TLS
        rc = ldap_pvt_tls_init();
+       if( rc != 0) {
+#ifdef NEW_LOGGING
+               LDAP_LOG(( "operation", LDAP_LEVEL_CRIT,
+                          "main: tls init failed: %d\n", rc ));
+#else
+               Debug( LDAP_DEBUG_ANY,
+                   "main: TLS init failed: %d\n",
+                   0, 0, 0 );
+#endif
+               rc = 1;
+               SERVICE_EXIT( ERROR_SERVICE_SPECIFIC_ERROR, 20 );
+               goto destroy;
+       }
 
-       if (rc || ldap_pvt_tls_init_def_ctx() != 0) {
+       rc = ldap_pvt_tls_init_def_ctx();
+       if( rc != 0) {
+#ifdef NEW_LOGGING
+               LDAP_LOG(( "operation", LDAP_LEVEL_CRIT,
+                          "main: tls init def ctx failed: %d\n", rc ));
+#else
+               Debug( LDAP_DEBUG_ANY,
+                   "main: TLS init def ctx failed: %d\n",
+                   0, 0, 0 );
+#endif
                rc = 1;
                SERVICE_EXIT( ERROR_SERVICE_SPECIFIC_ERROR, 20 );
                goto destroy;
@@ -519,6 +545,12 @@ stop:
 #endif
        slapd_daemon_destroy();
 
+       schema_destroy();
+
+#ifdef HAVE_TLS
+       ldap_pvt_tls_destroy();
+#endif
+
 #ifdef CSRIMALLOC
        mal_dumpleaktrace( leakfile );
 #endif