summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNalin Dahyabhai <nalin.dahyabhai@pobox.com>2008-09-09 19:24:38 -0400
committerNalin Dahyabhai <nalin.dahyabhai@pobox.com>2008-09-09 19:24:38 -0400
commitde66fb8cd72b3402e9d507ad825cacb9b696f5f0 (patch)
tree7761d8c99a55719ca16e453dd587330d26781cc4 /src
parent6015107ae3c3eff5fb99fe5452c2475b23c70fd6 (diff)
- simplify the backref chasing logic a bit more
Diffstat (limited to 'src')
-rw-r--r--src/back-shr.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/src/back-shr.c b/src/back-shr.c
index fac2da8..d06fed1 100644
--- a/src/back-shr.c
+++ b/src/back-shr.c
@@ -907,11 +907,8 @@ backend_shr_update_references_cb(const char *group, const char *set,
/* Start with this entry. */
format_add_sdn_list(&these_entries,
slapi_entry_get_dn(cbdata->e));
- /* The last link in the chain just contains data (and we know
- * that at the last link we have to find *this* entry), so
- * start at the next-to-last link and work backwards from
- * there. */
- for (j = ref_attr->n_links - 2;
+ /* Walk backwards. */
+ for (j = ref_attr->n_links - 1;
(j >= 0) && (these_entries != NULL);
j--) {
/* We can populate the "previous links" set using the
@@ -929,18 +926,21 @@ backend_shr_update_references_cb(const char *group, const char *set,
}
/* We may have entries at this point in the chain
* which point to other entries at this point in the
- * chain. */
- this_attr_link = &ref_attr->links[j];
- these_attrs[0] = this_attr_link->attribute;
- these_attrs[1] = NULL;
- these_bases = this_attr_link->base_sdn_list;
+ * chain -- unless it's the last one, which we know
+ * doesn't contain a DN. */
+ if (j < ref_attr->n_links - 1) {
+ this_attr_link = &ref_attr->links[j];
+ these_attrs[0] = this_attr_link->attribute;
+ these_attrs[1] = NULL;
+ these_bases = this_attr_link->base_sdn_list;
+ } else {
+ this_attr_link = NULL;
+ these_attrs[0] = NULL;
+ these_attrs[1] = NULL;
+ these_bases = NULL;
+ }
/* Search for entries which would be predecessors in
* the path to this entry. */
- slapi_log_error(SLAPI_LOG_PLUGIN,
- state->plugin_desc->spd_id,
- "searching for references through "
- "\"%s\" (link=%d)\n",
- these_attrs[0], j);
for (k = 0; these_entries[k] != 0; k++) {
slapi_log_error(SLAPI_LOG_PLUGIN,
state->plugin_desc->spd_id,
@@ -1023,7 +1023,9 @@ backend_shr_update_references_cb(const char *group, const char *set,
}
free(filter);
}
- /* Back up to process the list of predecessors. */
+ /* Back up to process the list of predecessors, unless
+ * this was the last link, in which case it's become
+ * our list of candidates. */
if (j > 0) {
format_free_sdn_list(these_entries);
these_entries = prev_entries;