[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: (ITS#8649) Issue when fetching the backend that will receive the contextCSN when we have glued databases



elecharny@gmail.com wrote:
> Using a function to compute the working backend, it could be something
> like :

Discussions really belong on the -devel list, not in the ITS.
>
> void setWorkingBackend( syncinfo_t *syncInfo, Backend *backend )
> {
>     if ( !syncInfo->si_wbe )
>     {
>         if ( SLAP_GLUE_SUBORDINATE( backend ) && !overlay_is_inst(
> backend, "syncprov" ) )
>         {
>             // The backend has a parent backend, fetch it. Note that we
> want to get the
>             // top parent, not one of the intermediary subordinate,
> unless one of them
>             // has a syncprov overlay declared. If the top level backend
>             // does not have a syncprov overlay declared, then we use
> the local DB
>             // as a working backend.
>             BackendDB *currentBackend = backend;
>             struct berval bv;
>             ber_str2bv( currentBackend->be_nsuffix[0].bv_val, 0, 0, &bv );
>             dnParent( &bv, &bv );
>
>             while ( ( currentBackend = select_backend( &bv, 0 ) ) != NULL )
>             {
>                 if ( overlay_is_inst( currentBackend, "syncprov" ) )
>                 {
>                     syncInfo->si_wbe = currentBackend;
>                     break;
>                 }
>
>                 dnParent( &bv, &bv );
>             }
>
>             if ( syncInfo->si_wbe == NULL )
>             {
>                 syncInfo->si_wbe = backend;
>             }
>         }
>         else
>         {
>             syncInfo->si_wbe = backend;
>         }
>
>         if ( SLAP_SYNC_SUBENTRY( syncInfo->si_wbe ) )
>         {
>             build_new_dn( &syncInfo->si_contextdn,
> &syncInfo->si_wbe->be_nsuffix[0], (struct berval *)
> &slap_ldapsync_cn_bv, NULL );
>         }
>         else
>         {
>             syncInfo->si_contextdn = syncInfo->si_wbe->be_nsuffix[0];
>         }
>     }
> }
>
>
> We call it with
>
>         setWorkingBackend( si, be );
>
>


-- 
   -- Howard Chu
   CTO, Symas Corp.           http://www.symas.com
   Director, Highland Sun     http://highlandsun.com/hyc/
   Chief Architect, OpenLDAP  http://www.openldap.org/project/