]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/syncrepl.c
fix ITS#3753
[openldap] / servers / slapd / syncrepl.c
index 767ed876669f68d67088c21ad8694993b70c97d1..ff49fc7df9d62fba37d5b98096d7533321b81da4 100644 (file)
@@ -42,37 +42,38 @@ struct nonpresent_entry {
 };
 
 typedef struct syncinfo_s {
-        struct slap_backend_db *si_be;
-        long                           si_rid;
-        struct berval          si_provideruri;
-               slap_bindconf           si_bindconf;
-        struct berval          si_filterstr;
-        struct berval          si_base;
-        int                                    si_scope;
-        int                                    si_attrsonly;
-               char                            *si_anfile;
-               AttributeName           *si_anlist;
-               AttributeName           *si_exanlist;
-               char                            **si_attrs;
-               char                            **si_exattrs;
-               int                                     si_allattrs;
-               int                                     si_allopattrs;
-               int                                     si_schemachecking;
-        int                                    si_type;
-        time_t                         si_interval;
-               time_t                          *si_retryinterval;
-               int                                     *si_retrynum_init;
-               int                                     *si_retrynum;
-               struct sync_cookie      si_syncCookie;
-        int                                    si_manageDSAit;
-        int                                    si_slimit;
-               int                                     si_tlimit;
-               int                                     si_refreshDelete;
-               int                                     si_refreshPresent;
-        Avlnode                                *si_presentlist;
-               LDAP                            *si_ld;
-               LDAP_LIST_HEAD(np, nonpresent_entry) si_nonpresentlist;
-               ldap_pvt_thread_mutex_t si_mutex;
+       struct slap_backend_db *si_be;
+       struct re_s                     *si_re;
+       long                            si_rid;
+       struct berval           si_provideruri;
+       slap_bindconf           si_bindconf;
+       struct berval           si_filterstr;
+       struct berval           si_base;
+       int                                     si_scope;
+       int                                     si_attrsonly;
+       char                            *si_anfile;
+       AttributeName           *si_anlist;
+       AttributeName           *si_exanlist;
+       char                            **si_attrs;
+       char                            **si_exattrs;
+       int                                     si_allattrs;
+       int                                     si_allopattrs;
+       int                                     si_schemachecking;
+       int                                     si_type;
+       time_t                          si_interval;
+       time_t                          *si_retryinterval;
+       int                                     *si_retrynum_init;
+       int                                     *si_retrynum;
+       struct sync_cookie      si_syncCookie;
+       int                                     si_manageDSAit;
+       int                                     si_slimit;
+       int                                     si_tlimit;
+       int                                     si_refreshDelete;
+       int                                     si_refreshPresent;
+       Avlnode                         *si_presentlist;
+       LDAP                            *si_ld;
+       LDAP_LIST_HEAD(np, nonpresent_entry) si_nonpresentlist;
+       ldap_pvt_thread_mutex_t si_mutex;
 } syncinfo_t;
 
 static int syncuuid_cmp( const void *, const void * );
@@ -882,7 +883,7 @@ done:
        return rc;
 }
 
-void *
+static void *
 do_syncrepl(
        void    *ctx,
        void    *arg )
@@ -2623,6 +2624,14 @@ add_syncrepl(
 
        rc = parse_syncrepl_line( cargv, cargc, si );
 
+       if ( rc == 0 ) {
+               si->si_be = be;
+               init_syncrepl( si );
+               si->si_re = ldap_pvt_runqueue_insert( &slapd_rq, si->si_interval,
+                       do_syncrepl, si, "do_syncrepl", be->be_suffix[0].bv_val );
+               if ( !si->si_re )
+                       rc = -1;
+       }
        if ( rc < 0 ) {
                Debug( LDAP_DEBUG_ANY, "failed to add syncinfo\n", 0, 0, 0 );
                syncinfo_free( si );    
@@ -2635,10 +2644,7 @@ add_syncrepl(
                if ( !si->si_schemachecking ) {
                        SLAP_DBFLAGS(be) |= SLAP_DBFLAG_NO_SCHEMA_CHECK;
                }
-               si->si_be = be;
                be->be_syncinfo = si;
-               init_syncrepl( si );
-               ldap_pvt_runqueue_insert( &slapd_rq,si->si_interval,do_syncrepl,si );
                return 0;
        }
 }
@@ -2726,7 +2732,7 @@ syncrepl_unparse( syncinfo_t *si, struct berval *bv )
                for (i=0; si->si_retryinterval[i]; i++) {
                        if ( space ) *ptr++ = ' ';
                        space = 1;
-                       ptr += sprintf( ptr, "%d", si->si_retryinterval[i] );
+                       ptr += sprintf( ptr, "%d ", si->si_retryinterval[i] );
                        if ( si->si_retrynum_init[i] == -1 )
                                *ptr++ = '+';
                        else
@@ -2763,7 +2769,7 @@ syncrepl_config(ConfigArgs *c) {
                struct re_s *re;
 
                if ( c->be->be_syncinfo ) {
-                       re = ldap_pvt_runqueue_find( &slapd_rq, do_syncrepl, c->be->be_syncinfo );
+                       re = c->be->be_syncinfo->si_re;
                        if ( re ) {
                                if ( ldap_pvt_runqueue_isrunning( &slapd_rq, re ))
                                        ldap_pvt_runqueue_stoptask( &slapd_rq, re );
@@ -2772,6 +2778,7 @@ syncrepl_config(ConfigArgs *c) {
                        syncinfo_free( c->be->be_syncinfo );
                        c->be->be_syncinfo = NULL;
                }
+               SLAP_DBFLAGS(c->be) &= ~(SLAP_DBFLAG_SHADOW|SLAP_DBFLAG_SYNC_SHADOW);
                return 0;
        }
        if(SLAP_SHADOW(c->be)) {