]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/main.c
Use LDAP_MOD_SOFTADD instead of LDAP_MOD_ADD when adding the new rdn as
[openldap] / servers / slapd / main.c
index 565688643cb1c68aa5eda0d2a4296ffc39323c47..4d91ee7847d095323e15df0467a5209321b7a9bf 100644 (file)
@@ -2,6 +2,7 @@
 
 #include <stdio.h>
 
+#include <ac/signal.h>
 #include <ac/socket.h>
 #include <ac/string.h>
 #include <ac/time.h>
@@ -71,7 +72,10 @@ main( int argc, char **argv )
        char            *configfile;
        char    *serverName;
 #ifdef LOG_LOCAL4
+       char *optstring = "d:f:ip:s:ul:";
        int     syslogUser = DEFAULT_SYSLOG_USER;
+#else
+       char *optstring = "d:f:ip:s:u";
 #endif
 
        configfile = SLAPD_DEFAULT_CONFIGFILE;
@@ -79,7 +83,7 @@ main( int argc, char **argv )
        g_argc = argc;
        g_argv = argv;
 
-       while ( (i = getopt( argc, argv, "d:f:ip:s:u" )) != EOF ) {
+       while ( (i = getopt( argc, argv, optstring )) != EOF ) {
                switch ( i ) {
 #ifdef LDAP_DEBUG
                case 'd':       /* turn on debugging */
@@ -141,12 +145,10 @@ main( int argc, char **argv )
                        break;
 
 #ifdef LOG_LOCAL4
-
                case 'l':       /* set syslog local user */
                        syslogUser = cnvt_str2int( optarg, syslog_types,
                                            DEFAULT_SYSLOG_USER );
                        break;
-
 #endif
 
                case 'u':       /* do udp */
@@ -189,20 +191,24 @@ main( int argc, char **argv )
        if ( ! inetd ) {
                int             status;
 
+               (void) SIGNAL( SIGPIPE, SIG_IGN );
+               (void) SIGNAL( LDAP_SIGUSR1, slap_do_nothing );
+               (void) SIGNAL( LDAP_SIGUSR2, slap_set_shutdown );
+               (void) SIGNAL( SIGTERM, slap_set_shutdown );
+               (void) SIGNAL( SIGINT, slap_set_shutdown );
+               (void) SIGNAL( SIGHUP, slap_set_shutdown );
+
                time( &starttime );
 
-               if ( pthread_create( &listener_tid, NULL, slapd_daemon,
-                   (void *) port ) != 0 ) {
+               if ( status = ldap_pvt_thread_create( &listener_tid, 0,
+                       slapd_daemon, (void *) port ) != 0 )
+               {
                        Debug( LDAP_DEBUG_ANY,
-                           "listener pthread_create failed\n", 0, 0, 0 );
+                           "listener ldap_pvt_thread_create failed (%d)\n", status, 0, 0 );
                        exit( 1 );
                }
 
-#ifdef HAVE_PTHREADS_FINAL
-               pthread_join( listener_tid, (void *) NULL );
-#else
-               pthread_join( listener_tid, (void *) &status );
-#endif
+               ldap_pvt_thread_join( listener_tid, (void *) NULL );
 
                return 0;
 
@@ -225,9 +231,9 @@ main( int argc, char **argv )
                c.c_sb.sb_ber.ber_buf = NULL;
                c.c_sb.sb_ber.ber_ptr = NULL;
                c.c_sb.sb_ber.ber_end = NULL;
-               pthread_mutex_init( &c.c_dnmutex, pthread_mutexattr_default );
-               pthread_mutex_init( &c.c_opsmutex, pthread_mutexattr_default );
-               pthread_mutex_init( &c.c_pdumutex, pthread_mutexattr_default );
+               ldap_pvt_thread_mutex_init( &c.c_dnmutex );
+               ldap_pvt_thread_mutex_init( &c.c_opsmutex );
+               ldap_pvt_thread_mutex_init( &c.c_pdumutex );
 #ifdef notdefcldap
                c.c_sb.sb_addrs = (void **) saddrlist;
                c.c_sb.sb_fromaddr = &faddr;
@@ -256,9 +262,9 @@ main( int argc, char **argv )
                ber_init( &ber, 0 );
                while ( (tag = ber_get_next( &c.c_sb, &len, &ber ))
                    == LDAP_TAG_MESSAGE ) {
-                       pthread_mutex_lock( &currenttime_mutex );
+                       ldap_pvt_thread_mutex_lock( &currenttime_mutex );
                        time( &currenttime );
-                       pthread_mutex_unlock( &currenttime_mutex );
+                       ldap_pvt_thread_mutex_unlock( &currenttime_mutex );
 
                        if ( (tag = ber_get_int( &ber, &msgid ))
                            != LDAP_TAG_MSGID ) {