]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/main.c
Apply ITS#12 fix from devel.
[openldap] / servers / slapd / main.c
index 322362febf0e9d0f1d5e8eb9db2e56ec676f526a..af2c86c8ef5e6cfad3ddc4230e964d501243ce80 100644 (file)
@@ -120,7 +120,7 @@ main( int argc, char **argv )
 #endif
 
                case 'f':       /* read config file */
-                       configfile = strdup( optarg );
+                       configfile = ch_strdup( optarg );
                        break;
 
                case 'i':       /* run from inetd */
@@ -148,9 +148,9 @@ main( int argc, char **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 ) {
@@ -177,7 +177,10 @@ main( int argc, char **argv )
 
                time( &starttime );
                pthread_attr_init( &attr );
+#ifdef DETACH_LISTENER_THREAD
+               /* we should detach it if we're going to join with it */
                pthread_attr_setdetachstate( &attr, PTHREAD_CREATE_DETACHED );
+#endif
 
 #if !defined(HAVE_PTHREADS_D4)
                /* POSIX_THREADS or compatible
@@ -201,7 +204,11 @@ main( int argc, char **argv )
                }
 #endif /* !draft4 */
                pthread_attr_destroy( &attr );
+#ifdef HAVE_PHREADS_FINAL
+               pthread_join( listener_tid, (void *) NULL );
+#else
                pthread_join( listener_tid, (void *) &status );
+#endif
                pthread_exit( 0 );
        } else {
                Connection              c;
@@ -243,7 +250,7 @@ main( int argc, char **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 );