]> git.sur5r.net Git - openldap/blob - servers/slurpd/replica.c
fixes ITS #1379; the replication test has been improved by adding modrdn entries
[openldap] / servers / slurpd / replica.c
1 /* $OpenLDAP$ */
2 /*
3  * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
4  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
5  */
6 /*
7  * Copyright (c) 1996 Regents of the University of Michigan.
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms are permitted
11  * provided that this notice is preserved and that due credit is given
12  * to the University of Michigan at Ann Arbor. The name of the University
13  * may not be used to endorse or promote products derived from this
14  * software without specific prior written permission. This software
15  * is provided ``as is'' without express or implied warranty.
16  */
17
18
19 /*
20  * replica.c - code to start up replica threads.
21  */
22
23 #include "portable.h"
24
25 #include <stdio.h>
26
27 #include "slurp.h"
28 #include "globals.h"
29
30
31 /*
32  * Just invoke the Ri's process() member function, and log the start and
33  * finish.
34  */
35 static void *
36 replicate(
37     void        *ri_arg
38 )
39 {
40     Ri          *ri = (Ri *) ri_arg;
41
42     Debug( LDAP_DEBUG_ARGS, "begin replication thread for %s:%d\n",
43             ((Ri *)ri)->ri_hostname, ((Ri *)ri)->ri_port, 0 );
44
45     ri->ri_process( ri );
46
47     Debug( LDAP_DEBUG_ARGS, "end replication thread for %s:%d\n",
48             ri->ri_hostname, ri->ri_port, 0 );
49     return NULL;
50 }
51
52
53
54 /*
55  * Start a detached thread for the given replica.
56  */
57 int
58 start_replica_thread(
59     Ri  *ri
60 )
61 {
62     /* POSIX_THREADS or compatible */
63     if ( ldap_pvt_thread_create( &(ri->ri_tid), 0, replicate,
64             (void *) ri ) != 0 ) {
65         Debug( LDAP_DEBUG_ANY, "replica \"%s:%d\" ldap_pvt_thread_create failed\n",
66                 ri->ri_hostname, ri->ri_port, 0 );
67         return -1;
68     }
69
70     return 0;
71 }