2 * Copyright (c) 1996 Regents of the University of Michigan.
5 * Redistribution and use in source and binary forms are permitted
6 * provided that this notice is preserved and that due credit is given
7 * to the University of Michigan at Ann Arbor. The name of the University
8 * may not be used to endorse or promote products derived from this
9 * software without specific prior written permission. This software
10 * is provided ``as is'' without express or implied warranty.
15 * replica.c - code to start up replica threads.
26 * Just invoke the Ri's process() member function, and log the start and
37 Debug( LDAP_DEBUG_ARGS, "begin replication thread for %s:%d\n",
38 ri->ri_hostname, ri->ri_port, 0 );
42 Debug( LDAP_DEBUG_ARGS, "end replication thread for %s:%d\n",
43 ri->ri_hostname, ri->ri_port, 0 );
50 * Start a detached thread for the given replica.
59 pthread_attr_init( &attr );
61 /* if main wants to join with us, we shouldn't detach */
62 pthread_attr_setdetachstate( &attr, PTHREAD_CREATE_DETACHED );
65 #ifndef THREAD_MIT_PTHREADS
66 /* POSIX_THREADS or compatible
67 * This is a draft 10 or standard pthreads implementation
69 if ( pthread_create( &(ri->ri_tid), &attr, (void *) replicate,
70 (void *) ri ) != 0 ) {
71 Debug( LDAP_DEBUG_ANY, "replica \"%s:%d\" pthread_create failed\n",
72 ri->ri_hostname, ri->ri_port, 0 );
73 pthread_attr_destroy( &attr );
76 #else /* !THREAD_MIT_PTHREADS */
78 * This is a draft 4 or earlier pthreads implementation
80 if ( pthread_create( &(ri->ri_tid), attr, (void *) replicate,
81 (void *) ri ) != 0 ) {
82 Debug( LDAP_DEBUG_ANY, "replica \"%s:%d\" pthread_create failed\n",
83 ri->ri_hostname, ri->ri_port, 0 );
84 pthread_attr_destroy( &attr );
87 #endif /* !THREAD_MIT_PTHREADS */
88 pthread_attr_destroy( &attr );