[Fedora-directory-commits] ldapserver/ldap/servers/slapd/back-ldbm dn2entry.c, 1.4, 1.4.2.1 import-threads.c, 1.8.2.1, 1.8.2.2 sort.c, 1.5, 1.5.2.1
Noriko Hosoi (nhosoi)
fedora-directory-commits at redhat.com
Thu Mar 2 01:12:39 UTC 2006
- Previous message (by thread): [Fedora-directory-commits] ldapserver/ldap/servers/slapd add.c, 1.5, 1.5.2.1 attr.c, 1.5.2.1, 1.5.2.2 ava.c, 1.4, 1.4.2.1 bind.c, 1.6, 1.6.2.1 compare.c, 1.4, 1.4.2.1 delete.c, 1.4, 1.4.2.1 dn.c, 1.6.2.1, 1.6.2.2 filter.c, 1.5, 1.5.2.1 modify.c, 1.7, 1.7.2.1 modrdn.c, 1.4, 1.4.2.1 passwd_extop.c, 1.6, 1.6.2.1 slapi-plugin.h, 1.8, 1.8.2.1
- Next message (by thread): [Fedora-directory-commits] mod_nss Makefile.am, 1.10, 1.11 Makefile.in, 1.17, 1.18 configure, 1.14, 1.15 configure.in, 1.10, 1.11 mod_nss.c, 1.10, 1.11 mod_nss.h, 1.9, 1.10 nss.conf.in, 1.7, 1.8 nss_engine_config.c, 1.9, 1.10 nss_engine_init.c, 1.16, 1.17 nss_engine_io.c, 1.4, 1.5 nss_engine_kernel.c, 1.3, 1.4 nss_engine_vars.c, 1.4, 1.5
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Author: nhosoi
Update of /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv11336/ldap/servers/slapd/back-ldbm
Modified Files:
Tag: Directory71RtmBranch
dn2entry.c import-threads.c sort.c
Log Message:
[159328] Tracking bug for Directory Server 7.1 Service Packs; Comment #50
ported internal diffs to the external CVS
Index: dn2entry.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/dn2entry.c,v
retrieving revision 1.4
retrieving revision 1.4.2.1
diff -u -r1.4 -r1.4.2.1
--- dn2entry.c 19 Apr 2005 22:07:38 -0000 1.4
+++ dn2entry.c 2 Mar 2006 01:12:31 -0000 1.4.2.1
@@ -109,58 +109,12 @@
}
/*
- * dn2entry_or_ancestor - look up dn in the cache/indexes and return the
- * corresponding entry. If the entry is not found, this function returns NULL
- * and sets ancestordn to the DN of highest entry in the tree matched.
- *
- * ancestordn should be initialized before calling this function.
- *
- * When the caller is finished with the entry returned, it should return it
- * to the cache:
- * e = dn2entry_or_ancestor( ... );
- * if ( NULL != e ) {
- * cache_return( &inst->inst_cache, &e );
- * }
- */
-struct backentry *
-dn2entry_or_ancestor(
- Slapi_Backend *be,
- const Slapi_DN *sdn,
- Slapi_DN *ancestordn,
- back_txn *txn,
- int *err
-)
-{
- struct backentry *e;
-
- LDAPDebug( LDAP_DEBUG_TRACE, "=> dn2entry_or_ancestor \"%s\"\n", slapi_sdn_get_dn(sdn), 0, 0 );
-
- /*
- * Fetch the entry asked for.
- */
-
- e= dn2entry(be,sdn,txn,err);
-
- if(e==NULL)
- {
- /*
- * could not find the entry named. crawl back up the dn and
- * stop at the first ancestor that does exist, or when we get
- * to the suffix.
- */
- e= dn2ancestor(be,sdn,ancestordn,txn,err);
- }
-
- LDAPDebug( LDAP_DEBUG_TRACE, "<= dn2entry_or_ancestor %p\n", e, 0, 0 );
- return( e );
-}
-
-/*
* Use the DN to fetch the parent of the entry.
* If the parent entry doesn't exist, keep working
* up the DN until we hit "" or an backend suffix.
*
- * ancestordn should be initialized before calling this function.
+ * ancestordn should be initialized before calling this function, and
+ * should be empty
*
* Returns NULL for no entry found.
*
@@ -184,18 +138,64 @@
LDAPDebug( LDAP_DEBUG_TRACE, "=> dn2ancestor \"%s\"\n", slapi_sdn_get_dn(sdn), 0, 0 );
- /* stop when we get to "", or a backend suffix point */
- slapi_sdn_done(ancestordn); /* free any previous contents */
- slapi_sdn_get_backend_parent(sdn,ancestordn,be);
- if ( !slapi_sdn_isempty(ancestordn) )
- {
- Slapi_DN *newsdn = slapi_sdn_dup(ancestordn);
- e = dn2entry_or_ancestor( be, newsdn, ancestordn, txn, err );
- slapi_sdn_free(&newsdn);
- }
-
- LDAPDebug( LDAP_DEBUG_TRACE, "<= dn2ancestor %p\n", e, 0, 0 );
- return( e );
+ /* first, check to see if the given sdn is empty or a root suffix of the
+ given backend - if so, it has no parent */
+ if (!slapi_sdn_isempty(sdn) && !slapi_be_issuffix( be, sdn )) {
+ Slapi_DN ancestorndn;
+ const char *ptr;
+
+ /* assign ancestordn to the parent of the given dn - ancestordn will contain
+ the "raw" unnormalized DN from the caller, so we can give back the DN
+ in the same format as we received it */
+ ptr = slapi_dn_find_parent(slapi_sdn_get_dn(sdn));
+ /* assign the ancestordn dn pointer to the parent of dn from sdn - sdn "owns"
+ the memory, but ancestordn points to it */
+ slapi_sdn_set_dn_byref(ancestordn, ptr); /* free any previous contents */
+ /* now, do the same for the normalized version */
+ /* ancestorndn holds the normalized version for iteration purposes and
+ because dn2entry needs the normalized dn */
+ ptr = slapi_dn_find_parent(slapi_sdn_get_ndn(sdn));
+ slapi_sdn_init_ndn_byref(&ancestorndn, ptr);
+
+ /*
+ At this point you may be wondering why I need both ancestorndn and
+ ancestordn. Because, with the slapi_sdn interface, you cannot set both
+ the dn and ndn byref at the same time. Whenever you call set_dn or set_ndn,
+ it calls slapi_sdn_done which wipes out the previous contents. I suppose I
+ could have added another API to allow you to pass them both in. Also, using
+ slapi_sdn_get_ndn(ancestordn) every time would result in making a copy then
+ normalizing the copy every time - not efficient.
+ So, why not just use a char* for the ancestorndn? Because dn2entry requires
+ a Slapi_DN with the normalized dn.
+ */
+
+ /* stop when we get to "", or a backend suffix point */
+ while (!e && !slapi_sdn_isempty(&ancestorndn) && !slapi_be_issuffix( be, &ancestorndn )) {
+ /* find the entry - it uses the ndn, so no further conversion is necessary */
+ e= dn2entry(be,&ancestorndn,txn,err);
+ if (!e) {
+ /* not found, so set ancestordn to its parent and try again */
+ ptr = slapi_dn_find_parent(slapi_sdn_get_ndn(&ancestorndn));
+ /* keep in mind that ptr points to the raw ndn pointer inside
+ ancestorndn which is still the ndn string "owned" by sdn, the
+ original dn we started with - we are careful not to touch
+ or change it */
+ slapi_sdn_set_ndn_byref(&ancestorndn, ptr); /* wipe out the previous contents */
+ /* now do the same for the unnormalized one */
+ ptr = slapi_dn_find_parent(slapi_sdn_get_dn(ancestordn));
+ slapi_sdn_set_dn_byref(ancestordn, ptr); /* wipe out the previous contents */
+ }
+ }
+
+ slapi_sdn_done(&ancestorndn);
+ }
+
+ /* post conditions:
+ e is the entry of the ancestor of sdn OR e is the suffix entry
+ OR e is NULL
+ ancestordn contains the unnormalized DN of e or is empty */
+ LDAPDebug( LDAP_DEBUG_TRACE, "<= dn2ancestor %p\n", e, 0, 0 );
+ return( e );
}
/*
Index: import-threads.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/import-threads.c,v
retrieving revision 1.8.2.1
retrieving revision 1.8.2.2
diff -u -r1.8.2.1 -r1.8.2.2
--- import-threads.c 20 Feb 2006 18:14:50 -0000 1.8.2.1
+++ import-threads.c 2 Mar 2006 01:12:31 -0000 1.8.2.2
@@ -986,7 +986,7 @@
int ret = 0;
struct attrinfo *parentid_ai;
Slapi_PBlock *pb = slapi_pblock_new();
- int shift = 0;
+ int shift = 0;
PR_ASSERT(info != NULL);
PR_ASSERT(inst != NULL);
@@ -1030,8 +1030,8 @@
/* Read that entry from the cache */
fi = import_fifo_fetch(job, id, 0, shift);
if (! fi) {
- import_log_notice(job, "WARNING: entry id %d is missing");
- shift++;
+ import_log_notice(job, "WARNING: entry id %d is missing", id);
+ shift++;
continue;
}
@@ -1052,7 +1052,7 @@
*/
if (job->flags & FLAG_ABORT) {
goto error;
- }
+ }
if (parent_status == IMPORT_ADD_OP_ATTRS_NO_PARENT) {
/* If this entry is a suffix entry, this is not a problem */
Index: sort.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/sort.c,v
retrieving revision 1.5
retrieving revision 1.5.2.1
diff -u -r1.5 -r1.5.2.1
--- sort.c 19 Apr 2005 22:07:38 -0000 1.5
+++ sort.c 2 Mar 2006 01:12:31 -0000 1.5.2.1
@@ -384,6 +384,7 @@
return_value = ber_scanf(ber,"a",&rtype);
if (LBER_ERROR == return_value) {
+ slapi_ch_free_string(&rtype);
rc = LDAP_PROTOCOL_ERROR;
goto err;
}
- Previous message (by thread): [Fedora-directory-commits] ldapserver/ldap/servers/slapd add.c, 1.5, 1.5.2.1 attr.c, 1.5.2.1, 1.5.2.2 ava.c, 1.4, 1.4.2.1 bind.c, 1.6, 1.6.2.1 compare.c, 1.4, 1.4.2.1 delete.c, 1.4, 1.4.2.1 dn.c, 1.6.2.1, 1.6.2.2 filter.c, 1.5, 1.5.2.1 modify.c, 1.7, 1.7.2.1 modrdn.c, 1.4, 1.4.2.1 passwd_extop.c, 1.6, 1.6.2.1 slapi-plugin.h, 1.8, 1.8.2.1
- Next message (by thread): [Fedora-directory-commits] mod_nss Makefile.am, 1.10, 1.11 Makefile.in, 1.17, 1.18 configure, 1.14, 1.15 configure.in, 1.10, 1.11 mod_nss.c, 1.10, 1.11 mod_nss.h, 1.9, 1.10 nss.conf.in, 1.7, 1.8 nss_engine_config.c, 1.9, 1.10 nss_engine_init.c, 1.16, 1.17 nss_engine_io.c, 1.4, 1.5 nss_engine_kernel.c, 1.3, 1.4 nss_engine_vars.c, 1.4, 1.5
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Fedora-directory-commits
mailing list