1 /* refint.c - referential integrity module */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2004-2008 The OpenLDAP Foundation.
6 * Portions Copyright 2004 Symas Corporation.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted only as authorized by the OpenLDAP
13 * A copy of this license is available in the file LICENSE in the
14 * top-level directory of the distribution or, alternatively, at
15 * <http://www.OpenLDAP.org/license.html>.
18 * This work was initially developed by Symas Corp. for inclusion in
19 * OpenLDAP Software. This work was sponsored by Hewlett-Packard.
24 /* This module maintains referential integrity for a set of
25 * DN-valued attributes by searching for all references to a given
26 * DN whenever the DN is changed or its entry is deleted, and making
27 * the appropriate update.
29 * Updates are performed using the database rootdn in a separate task
30 * to allow the original operation to complete immediately.
33 #ifdef SLAPD_OVER_REFINT
37 #include <ac/string.h>
38 #include <ac/socket.h>
44 static slap_overinst refint;
46 /* The DN to use in the ModifiersName for all refint updates */
47 static BerValue refint_dn = BER_BVC("cn=Referential Integrity Overlay");
48 static BerValue refint_ndn = BER_BVC("cn=referential integrity overlay");
50 typedef struct refint_attrs_s {
51 struct refint_attrs_s *next;
52 AttributeDescription *attr;
60 typedef struct dependents_s {
61 struct dependents_s *next;
62 BerValue dn; /* target dn */
67 typedef struct refint_q {
68 struct refint_q *next;
69 struct refint_data_s *rdata;
70 dependent_data *attrs; /* entries and attrs returned from callback */
78 typedef struct refint_data_s {
79 const char *message; /* breadcrumbs */
80 struct refint_attrs_s *attrs; /* list of known attrs */
81 BerValue dn; /* basedn in parent, */
82 BerValue nothing; /* the nothing value, if needed */
83 BerValue nnothing; /* normalized nothingness */
87 ldap_pvt_thread_mutex_t qmutex;
90 #define RUNQ_INTERVAL 36000 /* a long time */
92 static MatchingRule *mr_dnSubtreeMatch;
99 static ConfigDriver refint_cf_gen;
101 static ConfigTable refintcfg[] = {
102 { "refint_attributes", "attribute...", 2, 0, 0,
103 ARG_MAGIC|REFINT_ATTRS, refint_cf_gen,
104 "( OLcfgOvAt:11.1 NAME 'olcRefintAttribute' "
105 "DESC 'Attributes for referential integrity' "
106 "EQUALITY caseIgnoreMatch "
107 "SYNTAX OMsDirectoryString )", NULL, NULL },
108 { "refint_nothing", "string", 2, 2, 0,
109 ARG_DN|ARG_MAGIC|REFINT_NOTHING, refint_cf_gen,
110 "( OLcfgOvAt:11.2 NAME 'olcRefintNothing' "
111 "DESC 'Replacement DN to supply when needed' "
112 "SYNTAX OMsDN SINGLE-VALUE )", NULL, NULL },
113 { NULL, NULL, 0, 0, 0, ARG_IGNORED }
116 static ConfigOCs refintocs[] = {
117 { "( OLcfgOvOc:11.1 "
118 "NAME 'olcRefintConfig' "
119 "DESC 'Referential integrity configuration' "
120 "SUP olcOverlayConfig "
121 "MAY ( olcRefintAttribute $ olcRefintNothing ) )",
122 Cft_Overlay, refintcfg },
127 refint_cf_gen(ConfigArgs *c)
129 slap_overinst *on = (slap_overinst *)c->bi;
130 refint_data *dd = (refint_data *)on->on_bi.bi_private;
131 refint_attrs *ip, *pip, **pipp = NULL;
132 AttributeDescription *ad;
134 int rc = ARG_BAD_CONF;
138 case SLAP_CONFIG_EMIT:
143 value_add_one( &c->rvalue_vals,
144 &ip->attr->ad_cname );
150 if ( !BER_BVISEMPTY( &dd->nothing )) {
151 rc = value_add_one( &c->rvalue_vals,
154 rc = value_add_one( &c->rvalue_nvals,
164 case LDAP_MOD_DELETE:
177 /* delete from linked list */
178 for ( i=0; i < c->valx; ++i ) {
179 pipp = &(*pipp)->next;
182 *pipp = (*pipp)->next;
184 /* AttributeDescriptions are global so
185 * shouldn't be freed here... */
191 if ( dd->nothing.bv_val )
192 ber_memfree ( dd->nothing.bv_val );
193 if ( dd->nnothing.bv_val )
194 ber_memfree ( dd->nnothing.bv_val );
195 dd->nothing.bv_len = 0;
196 dd->nnothing.bv_len = 0;
203 case SLAP_CONFIG_ADD:
204 /* fallthrough to LDAP_MOD_ADD */
209 for ( i=1; i < c->argc; ++i ) {
211 if ( slap_str2ad ( c->argv[i], &ad, &text )
214 sizeof ( refint_attrs ) );
216 ip->next = dd->attrs;
219 snprintf( c->cr_msg, sizeof( c->cr_msg ),
220 "%s <%s>: %s", c->argv[0], c->argv[i], text );
221 Debug ( LDAP_DEBUG_CONFIG|LDAP_DEBUG_NONE,
222 "%s: %s\n", c->log, c->cr_msg, 0 );
228 if ( dd->nothing.bv_val )
229 ber_memfree ( dd->nothing.bv_val );
230 if ( dd->nnothing.bv_val )
231 ber_memfree ( dd->nnothing.bv_val );
232 dd->nothing = c->value_dn;
233 dd->nnothing = c->value_ndn;
248 ** allocate new refint_data;
249 ** store in on_bi.bi_private;
259 slap_overinst *on = (slap_overinst *)be->bd_info;
260 refint_data *id = ch_calloc(1,sizeof(refint_data));
262 id->message = "_init";
263 on->on_bi.bi_private = id;
264 ldap_pvt_thread_mutex_init( &id->qmutex );
274 slap_overinst *on = (slap_overinst *)be->bd_info;
276 if ( on->on_bi.bi_private ) {
277 refint_data *id = on->on_bi.bi_private;
278 on->on_bi.bi_private = NULL;
279 ldap_pvt_thread_mutex_destroy( &id->qmutex );
286 ** initialize, copy basedn if not already set
296 slap_overinst *on = (slap_overinst *)be->bd_info;
297 refint_data *id = on->on_bi.bi_private;
298 id->message = "_open";
300 if ( BER_BVISNULL( &id->dn )) {
301 if ( BER_BVISNULL( &be->be_nsuffix[0] ))
303 ber_dupbv( &id->dn, &be->be_nsuffix[0] );
310 ** foreach configured attribute:
313 ** (do not) free id->message;
314 ** reset on_bi.bi_private;
315 ** free our config data;
325 slap_overinst *on = (slap_overinst *) be->bd_info;
326 refint_data *id = on->on_bi.bi_private;
327 refint_attrs *ii, *ij;
328 id->message = "_close";
330 for(ii = id->attrs; ii; ii = ij) {
336 ch_free( id->dn.bv_val );
337 BER_BVZERO( &id->dn );
338 ch_free( id->nothing.bv_val );
339 BER_BVZERO( &id->nothing );
340 ch_free( id->nnothing.bv_val );
341 BER_BVZERO( &id->nnothing );
348 ** generates a list of Attributes from search results
359 refint_q *rq = op->o_callback->sc_private;
360 refint_data *dd = rq->rdata;
361 refint_attrs *ia, *da = dd->attrs, *na;
365 Debug(LDAP_DEBUG_TRACE, "refint_search_cb <%s>\n",
366 rs->sr_entry ? rs->sr_entry->e_name.bv_val : "NOTHING", 0, 0);
368 if (rs->sr_type != REP_SEARCH || !rs->sr_entry) return(0);
371 ** foreach configured attribute type:
372 ** if this attr exists in the search result,
373 ** and it has a value matching the target:
375 ** if this is a delete and there's only one value:
376 ** allocate the same attr again;
380 ip = op->o_tmpalloc(sizeof(dependent_data), op->o_tmpmemctx );
381 ber_dupbv_x( &ip->dn, &rs->sr_entry->e_name, op->o_tmpmemctx );
382 ber_dupbv_x( &ip->ndn, &rs->sr_entry->e_nname, op->o_tmpmemctx );
383 ip->next = rq->attrs;
386 for(ia = da; ia; ia = ia->next) {
387 if ( (a = attr_find(rs->sr_entry->e_attrs, ia->attr) ) ) {
388 int first = -1, count = 0, deleted = 0;
392 for(i = 0, b = a->a_nvals; b[i].bv_val; i++) {
395 if(dnIsSuffix(&b[i], &rq->oldndn)) {
396 /* first match? create structure */
398 na = op->o_tmpcalloc( 1,
399 sizeof( refint_attrs ),
401 na->next = ip->attrs;
405 /* delete, or exact match? note it's first match */
406 if ( BER_BVISEMPTY( &rq->newdn ) &&
407 b[i].bv_len == rq->oldndn.bv_len )
413 /* if it's a rename, or a subordinate match,
414 * save old and build new dn */
415 if ( !BER_BVISEMPTY( &rq->newdn ) &&
416 b[i].bv_len != rq->oldndn.bv_len )
418 struct berval newsub, newdn, olddn, oldndn;
420 /* if not first, save first as well */
423 ber_dupbv_x( &olddn, &a->a_vals[first], op->o_tmpmemctx );
424 ber_bvarray_add_x( &na->old_vals, &olddn, op->o_tmpmemctx );
425 ber_dupbv_x( &oldndn, &a->a_nvals[first], op->o_tmpmemctx );
426 ber_bvarray_add_x( &na->old_nvals, &oldndn, op->o_tmpmemctx );
429 newsub = a->a_vals[first];
430 newsub.bv_len -= rq->olddn.bv_len + 1;
432 build_new_dn( &newdn, &rq->newdn, &newsub, op->o_tmpmemctx );
434 ber_bvarray_add_x( &na->new_vals, &newdn, op->o_tmpmemctx );
436 newsub = a->a_nvals[first];
437 newsub.bv_len -= rq->oldndn.bv_len + 1;
439 build_new_dn( &newdn, &rq->newndn, &newsub, op->o_tmpmemctx );
441 ber_bvarray_add_x( &na->new_nvals, &newdn, op->o_tmpmemctx );
446 ber_dupbv_x( &olddn, &a->a_vals[i], op->o_tmpmemctx );
447 ber_bvarray_add_x( &na->old_vals, &olddn, op->o_tmpmemctx );
448 ber_dupbv_x( &oldndn, &a->a_nvals[i], op->o_tmpmemctx );
449 ber_bvarray_add_x( &na->old_nvals, &oldndn, op->o_tmpmemctx );
452 newsub = a->a_vals[i];
453 newsub.bv_len -= rq->olddn.bv_len + 1;
455 build_new_dn( &newdn, &rq->newdn, &newsub, op->o_tmpmemctx );
457 ber_bvarray_add_x( &na->new_vals, &newdn, op->o_tmpmemctx );
459 newsub = a->a_nvals[i];
460 newsub.bv_len -= rq->oldndn.bv_len + 1;
462 build_new_dn( &newdn, &rq->newndn, &newsub, op->o_tmpmemctx );
464 ber_bvarray_add_x( &na->new_nvals, &newdn, op->o_tmpmemctx );
468 if ( BER_BVISEMPTY( &rq->newdn ) ) {
473 /* If this is a delete and no value would be left, and
474 * we have a nothing DN configured, allocate the attr again.
476 if ( count == deleted && !BER_BVISNULL(&dd->nothing) )
478 na = op->o_tmpcalloc( 1,
479 sizeof( refint_attrs ),
481 na->next = ip->attrs;
486 Debug( LDAP_DEBUG_TRACE, "refint_search_cb: %s: %s (#%d)\n",
487 a->a_desc->ad_cname.bv_val, rq->olddn.bv_val, count );
502 dependent_data *dp, *dp_next;
505 op->o_callback->sc_response = refint_search_cb;
506 op->o_req_dn = op->o_bd->be_suffix[ 0 ];
507 op->o_req_ndn = op->o_bd->be_nsuffix[ 0 ];
508 op->o_dn = op->o_bd->be_rootdn;
509 op->o_ndn = op->o_bd->be_rootndn;
512 rc = op->o_bd->be_search( op, rs );
514 if ( rc != LDAP_SUCCESS ) {
515 Debug( LDAP_DEBUG_TRACE,
516 "refint_repair: search failed: %d\n",
521 /* safety? paranoid just in case */
522 if ( op->o_callback->sc_private == NULL ) {
523 Debug( LDAP_DEBUG_TRACE,
524 "refint_repair: callback wiped out sc_private?!\n",
529 /* Set up the Modify requests */
530 op->o_callback->sc_response = &slap_null_cb;
533 * [our search callback builds a list of attrs]
535 * make sure its dn has a backend;
536 * build Modification* chain;
537 * call the backend modify function;
541 for ( dp = rq->attrs; dp; dp = dp_next ) {
543 SlapReply rs2 = { 0 };
545 Modifications *m, *first = NULL;
549 op2.o_tag = LDAP_REQ_MODIFY;
550 op2.orm_modlist = NULL;
551 op2.o_req_dn = dp->dn;
552 op2.o_req_ndn = dp->ndn;
553 op2.o_bd = select_backend( &dp->ndn, 1 );
555 Debug( LDAP_DEBUG_TRACE,
556 "refint_repair: no backend for DN %s!\n",
557 dp->dn.bv_val, 0, 0 );
561 rs2.sr_type = REP_RESULT;
562 for ( ra = dp->attrs; ra; ra = dp->attrs ) {
565 dp->attrs = ra->next;
566 /* Set our ModifiersName */
567 if ( SLAP_LASTMOD( op->o_bd ) ) {
568 m = op2.o_tmpalloc( sizeof(Modifications) +
569 4*sizeof(BerValue), op2.o_tmpmemctx );
570 m->sml_next = op2.orm_modlist;
574 m->sml_op = LDAP_MOD_REPLACE;
575 m->sml_flags = SLAP_MOD_INTERNAL;
576 m->sml_desc = slap_schema.si_ad_modifiersName;
577 m->sml_type = m->sml_desc->ad_cname;
579 m->sml_values = (BerVarray)(m+1);
580 m->sml_nvalues = m->sml_values+2;
581 BER_BVZERO( &m->sml_values[1] );
582 BER_BVZERO( &m->sml_nvalues[1] );
583 m->sml_values[0] = refint_dn;
584 m->sml_nvalues[0] = refint_ndn;
586 if ( !BER_BVISEMPTY( &rq->newdn ) || ( ra->next &&
587 ra->attr == ra->next->attr ) )
589 len = sizeof(Modifications);
591 if ( ra->new_vals == NULL ) {
592 len += 4*sizeof(BerValue);
595 m = op2.o_tmpalloc( len, op2.o_tmpmemctx );
596 m->sml_next = op2.orm_modlist;
600 m->sml_op = LDAP_MOD_ADD;
602 m->sml_desc = ra->attr;
603 m->sml_type = ra->attr->ad_cname;
604 if ( ra->new_vals == NULL ) {
605 m->sml_values = (BerVarray)(m+1);
606 m->sml_nvalues = m->sml_values+2;
607 BER_BVZERO( &m->sml_values[1] );
608 BER_BVZERO( &m->sml_nvalues[1] );
610 if ( BER_BVISEMPTY( &rq->newdn ) ) {
611 op2.o_tmpfree( ra, op2.o_tmpmemctx );
613 dp->attrs = ra->next;
614 m->sml_values[0] = id->nothing;
615 m->sml_nvalues[0] = id->nnothing;
617 m->sml_values[0] = rq->newdn;
618 m->sml_nvalues[0] = rq->newndn;
621 m->sml_values = ra->new_vals;
622 m->sml_nvalues = ra->new_nvals;
623 m->sml_numvals = ra->ra_numvals;
627 len = sizeof(Modifications);
628 if ( ra->old_vals == NULL ) {
629 len += 4*sizeof(BerValue);
632 m = op2.o_tmpalloc( len, op2.o_tmpmemctx );
633 m->sml_next = op2.orm_modlist;
637 m->sml_op = LDAP_MOD_DELETE;
639 m->sml_desc = ra->attr;
640 m->sml_type = ra->attr->ad_cname;
641 if ( ra->old_vals == NULL ) {
643 m->sml_values = (BerVarray)(m+1);
644 m->sml_nvalues = m->sml_values+2;
645 m->sml_values[0] = rq->olddn;
646 m->sml_nvalues[0] = rq->oldndn;
647 BER_BVZERO( &m->sml_values[1] );
648 BER_BVZERO( &m->sml_nvalues[1] );
650 m->sml_values = ra->old_vals;
651 m->sml_nvalues = ra->old_nvals;
652 m->sml_numvals = ra->ra_numvals;
654 op2.o_tmpfree( ra, op2.o_tmpmemctx );
657 op2.o_dn = op2.o_bd->be_rootdn;
658 op2.o_ndn = op2.o_bd->be_rootndn;
659 slap_op_time( &op2.o_time, &op2.o_tincr );
660 if ( ( rc = op2.o_bd->be_modify( &op2, &rs2 ) ) != LDAP_SUCCESS ) {
661 Debug( LDAP_DEBUG_TRACE,
662 "refint_repair: dependent modify failed: %d\n",
666 while ( ( m = op2.orm_modlist ) ) {
667 op2.orm_modlist = m->sml_next;
668 if ( m->sml_values && m->sml_values != (BerVarray)(m+1) ) {
669 ber_bvarray_free_x( m->sml_values, op2.o_tmpmemctx );
670 ber_bvarray_free_x( m->sml_nvalues, op2.o_tmpmemctx );
672 op2.o_tmpfree( m, op2.o_tmpmemctx );
673 if ( m == first ) break;
675 slap_mods_free( op2.orm_modlist, 1 );
676 op2.o_tmpfree( dp->ndn.bv_val, op2.o_tmpmemctx );
677 op2.o_tmpfree( dp->dn.bv_val, op2.o_tmpmemctx );
678 op2.o_tmpfree( dp, op2.o_tmpmemctx );
685 refint_qtask( void *ctx, void *arg )
687 struct re_s *rtask = arg;
688 refint_data *id = rtask->arg;
689 Connection conn = {0};
690 OperationBuffer opbuf;
692 SlapReply rs = {REP_RESULT};
693 slap_callback cb = { NULL, NULL, NULL, NULL };
698 connection_fake_init( &conn, &opbuf, ctx );
702 ** build a search filter for all configured attributes;
703 ** populate our Operation;
704 ** pass our data (attr list, dn) to backend via sc_private;
705 ** call the backend search function;
706 ** nb: (|(one=thing)) is valid, but do smart formatting anyway;
707 ** nb: 16 is arbitrarily a dozen or so extra bytes;
711 ftop.f_choice = LDAP_FILTER_OR;
714 op->ors_filter = &ftop;
715 for(ip = id->attrs; ip; ip = ip->next) {
716 fptr = op->o_tmpcalloc( sizeof(Filter) + sizeof(MatchingRuleAssertion),
717 1, op->o_tmpmemctx );
718 /* Use (attr:dnSubtreeMatch:=value) to catch subtree rename
719 * and subtree delete where supported */
720 fptr->f_choice = LDAP_FILTER_EXT;
721 fptr->f_mra = (MatchingRuleAssertion *)(fptr+1);
722 fptr->f_mr_rule = mr_dnSubtreeMatch;
723 fptr->f_mr_rule_text = mr_dnSubtreeMatch->smr_bvoid;
724 fptr->f_mr_desc = ip->attr;
725 fptr->f_mr_dnattrs = 0;
726 fptr->f_next = ftop.f_or;
732 ldap_pvt_thread_mutex_lock( &id->qmutex );
735 id->qhead = rq->next;
739 ldap_pvt_thread_mutex_unlock( &id->qmutex );
743 for (fptr = ftop.f_or; fptr; fptr = fptr->f_next )
744 fptr->f_mr_value = rq->oldndn;
746 filter2bv_x( op, op->ors_filter, &op->ors_filterstr );
748 /* callback gets the searched dn instead */
750 cb.sc_response = refint_search_cb;
751 op->o_callback = &cb;
752 op->o_tag = LDAP_REQ_SEARCH;
753 op->ors_scope = LDAP_SCOPE_SUBTREE;
754 op->ors_deref = LDAP_DEREF_NEVER;
755 op->ors_limit = NULL;
756 op->ors_slimit = SLAP_NO_LIMIT;
757 op->ors_tlimit = SLAP_NO_LIMIT;
760 op->ors_attrs = slap_anlist_no_attrs;
762 slap_op_time( &op->o_time, &op->o_tincr );
764 if ( rq->db != NULL ) {
766 refint_repair( op, &rs, id, rq );
771 LDAP_STAILQ_FOREACH( be, &backendDB, be_next ) {
772 /* we may want to skip cn=config */
773 if ( be == LDAP_STAILQ_FIRST(&backendDB) ) {
777 if ( be->be_search && be->be_modify ) {
779 refint_repair( op, &rs, id, rq );
784 if ( !BER_BVISNULL( &rq->newndn )) {
785 ch_free( rq->newndn.bv_val );
786 ch_free( rq->newdn.bv_val );
788 ch_free( rq->oldndn.bv_val );
789 ch_free( rq->olddn.bv_val );
794 for ( fptr = ftop.f_or; fptr; ) {
795 Filter *f_next = fptr->f_next;
796 op->o_tmpfree( fptr, op->o_tmpmemctx );
800 /* wait until we get explicitly scheduled again */
801 ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex );
802 ldap_pvt_runqueue_stoptask( &slapd_rq, id->qtask );
803 ldap_pvt_runqueue_resched( &slapd_rq,id->qtask, 1 );
804 ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex );
811 ** search for matching records and modify them
820 slap_overinst *on = (slap_overinst *) op->o_bd->bd_info;
821 refint_data *id = on->on_bi.bi_private;
825 BackendDB *db = NULL;
828 id->message = "_refint_response";
830 /* If the main op failed or is not a Delete or ModRdn, ignore it */
831 if (( op->o_tag != LDAP_REQ_DELETE && op->o_tag != LDAP_REQ_MODRDN ) ||
832 rs->sr_err != LDAP_SUCCESS )
833 return SLAP_CB_CONTINUE;
836 ** validate (and count) the list of attrs;
840 for(ip = id->attrs, ac = 0; ip; ip = ip->next, ac++);
842 Debug( LDAP_DEBUG_TRACE,
843 "refint_response called without any attributes\n", 0, 0, 0 );
844 return SLAP_CB_CONTINUE;
848 ** find the backend that matches our configured basedn;
849 ** make sure it exists and has search and modify methods;
853 if ( on->on_info->oi_origdb != frontendDB ) {
854 db = select_backend(&id->dn, 1);
857 if ( !db->be_search || !db->be_modify ) {
858 Debug( LDAP_DEBUG_TRACE,
859 "refint_response: backend missing search and/or modify\n",
861 return SLAP_CB_CONTINUE;
864 Debug( LDAP_DEBUG_TRACE,
865 "refint_response: no backend for our baseDN %s??\n",
866 id->dn.bv_val, 0, 0 );
867 return SLAP_CB_CONTINUE;
871 rq = ch_calloc( 1, sizeof( refint_q ));
872 ber_dupbv( &rq->olddn, &op->o_req_dn );
873 ber_dupbv( &rq->oldndn, &op->o_req_ndn );
877 if ( op->o_tag == LDAP_REQ_MODRDN ) {
878 if ( op->oq_modrdn.rs_newSup ) {
879 pdn = *op->oq_modrdn.rs_newSup;
881 dnParent( &op->o_req_dn, &pdn );
883 build_new_dn( &rq->newdn, &pdn, &op->orr_newrdn, NULL );
884 if ( op->oq_modrdn.rs_nnewSup ) {
885 pdn = *op->oq_modrdn.rs_nnewSup;
887 dnParent( &op->o_req_ndn, &pdn );
889 build_new_dn( &rq->newndn, &pdn, &op->orr_nnewrdn, NULL );
892 ldap_pvt_thread_mutex_lock( &id->qmutex );
894 id->qtail->next = rq;
899 ldap_pvt_thread_mutex_unlock( &id->qmutex );
902 ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex );
904 id->qtask = ldap_pvt_runqueue_insert( &slapd_rq, RUNQ_INTERVAL,
905 refint_qtask, id, "refint_qtask",
906 op->o_bd->be_suffix[0].bv_val );
909 if ( !ldap_pvt_runqueue_isrunning( &slapd_rq, id->qtask ) &&
910 !id->qtask->next_sched.tv_sec ) {
911 id->qtask->interval.tv_sec = 0;
912 ldap_pvt_runqueue_resched( &slapd_rq, id->qtask, 0 );
913 id->qtask->interval.tv_sec = RUNQ_INTERVAL;
917 ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex );
919 slap_wake_listener();
921 return SLAP_CB_CONTINUE;
925 ** init_module is last so the symbols resolve "for free" --
926 ** it expects to be called automagically during dynamic module initialization
929 int refint_initialize() {
932 mr_dnSubtreeMatch = mr_find( "dnSubtreeMatch" );
933 if ( mr_dnSubtreeMatch == NULL ) {
934 Debug( LDAP_DEBUG_ANY, "refint_initialize: "
935 "unable to find MatchingRule 'dnSubtreeMatch'.\n",
940 /* statically declared just after the #includes at top */
941 refint.on_bi.bi_type = "refint";
942 refint.on_bi.bi_db_init = refint_db_init;
943 refint.on_bi.bi_db_destroy = refint_db_destroy;
944 refint.on_bi.bi_db_open = refint_open;
945 refint.on_bi.bi_db_close = refint_close;
946 refint.on_response = refint_response;
948 refint.on_bi.bi_cf_ocs = refintocs;
949 rc = config_register_schema ( refintcfg, refintocs );
952 return(overlay_register(&refint));
955 #if SLAPD_OVER_REFINT == SLAPD_MOD_DYNAMIC && defined(PIC)
956 int init_module(int argc, char *argv[]) {
957 return refint_initialize();
961 #endif /* SLAPD_OVER_REFINT */