From: Ralf Haferkamp Date: Tue, 23 Apr 2002 15:28:11 +0000 (+0000) Subject: - some code cleanups X-Git-Tag: OPENLDAP_REL_ENG_2_MP~150 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=bef9945dffd535b1ef1d389e895e4f5bb9c22309;p=openldap - some code cleanups - fix for the client caching code (cache is flushed after modifications rather than removing only the changed entry) The code was submitted by Jeff Costlow under the following terms: Copyright 2002, F5 Networks, Inc, All rights reserved. This software is not subject to any license of F5 Networks. This is free software; you can redistribute and use it under the same terms as OpenLDAP itself. --- diff --git a/contrib/ldapc++/src/LDAPAsynConnection.cpp b/contrib/ldapc++/src/LDAPAsynConnection.cpp index 2c1be7a299..6a5d5c464c 100644 --- a/contrib/ldapc++/src/LDAPAsynConnection.cpp +++ b/contrib/ldapc++/src/LDAPAsynConnection.cpp @@ -31,6 +31,7 @@ LDAPAsynConnection::LDAPAsynConnection(const string& hostname, int port, DEBUG(LDAP_DEBUG_CONSTRUCT | LDAP_DEBUG_PARAMETER, " host:" << hostname << endl << " port:" << port << endl); cur_session=0; + m_constr = 0; this->init(hostname, port); this->setConstraints(cons); } diff --git a/contrib/ldapc++/src/LDAPAsynConnection.h b/contrib/ldapc++/src/LDAPAsynConnection.h index d57035d949..fdef9ccd5f 100644 --- a/contrib/ldapc++/src/LDAPAsynConnection.h +++ b/contrib/ldapc++/src/LDAPAsynConnection.h @@ -160,7 +160,8 @@ class LDAPAsynConnection{ * @param cons A set of constraints that should be used with this * request */ - LDAPMessageQueue* compare(const std::string& dn, const LDAPAttribute& attr, + LDAPMessageQueue* compare(const std::string& dn, + const LDAPAttribute& attr, const LDAPConstraints *cons=0); /** Add an entry to the directory @@ -179,12 +180,13 @@ class LDAPAsynConnection{ * destination server, a LDAPException-object contains the * error that occured. * @param dn Distiguished Name of the Entry to modify - * @param modstd::list A set of modification that should be applied + * @param modlist A set of modification that should be applied * to the Entry * @param cons A set of constraints that should be used with this * request */ - LDAPMessageQueue* modify(const std::string& dn, const LDAPModList *modlist, + LDAPMessageQueue* modify(const std::string& dn, + const LDAPModList *modlist, const LDAPConstraints *cons=0); /** modify the DN of an entry @@ -201,7 +203,8 @@ class LDAPAsynConnection{ * @param newParentDN The DN of the new parent entry of the entry * 0 to keep the old one */ - LDAPMessageQueue* rename(const std::string& dn, const std::string& newRDN, + LDAPMessageQueue* rename(const std::string& dn, + const std::string& newRDN, bool delOldRDN=false, const std::string& newParentDN="", const LDAPConstraints* cons=0); diff --git a/contrib/ldapc++/src/LDAPDeleteRequest.cpp b/contrib/ldapc++/src/LDAPDeleteRequest.cpp index e6fbb251b0..78d086f5fc 100644 --- a/contrib/ldapc++/src/LDAPDeleteRequest.cpp +++ b/contrib/ldapc++/src/LDAPDeleteRequest.cpp @@ -37,7 +37,8 @@ LDAPDeleteRequest::~LDAPDeleteRequest(){ "LDAPDeleteRequest::~LDAPDeleteRequest()" << endl); // TODO -- flush the entire cache here? or does this invalidate // cached searches that may have found the deleted entry. - m_connection->uncache_entry(m_dn); + // m_connection->uncache_entry(m_dn); + m_connection->flush_cache(); } LDAPMessageQueue* LDAPDeleteRequest::sendRequest(){ diff --git a/contrib/ldapc++/src/LDAPEntry.cpp b/contrib/ldapc++/src/LDAPEntry.cpp index 3af69cc593..eb3dd5d6ab 100644 --- a/contrib/ldapc++/src/LDAPEntry.cpp +++ b/contrib/ldapc++/src/LDAPEntry.cpp @@ -30,7 +30,7 @@ LDAPEntry::LDAPEntry(const LDAPAsynConnection *ld, LDAPMessage *msg){ DEBUG(LDAP_DEBUG_CONSTRUCT,"LDAPEntry::LDAPEntry()" << endl); char* tmp=ldap_get_dn(ld->getSessionHandle(),msg); m_dn=string(tmp); - free(tmp); + ldap_memfree(tmp); m_attrs = new LDAPAttributeList(ld, msg); } @@ -56,7 +56,7 @@ void LDAPEntry::setAttributes(LDAPAttributeList *attrs){ m_attrs=attrs; } -const string LDAPEntry::getDN() const{ +const string& LDAPEntry::getDN() const{ DEBUG(LDAP_DEBUG_TRACE,"LDAPEntry::getDN()" << endl); return m_dn; } diff --git a/contrib/ldapc++/src/LDAPEntry.h b/contrib/ldapc++/src/LDAPEntry.h index ebd4153f05..c49e26d722 100644 --- a/contrib/ldapc++/src/LDAPEntry.h +++ b/contrib/ldapc++/src/LDAPEntry.h @@ -59,7 +59,7 @@ class LDAPEntry{ /** * @returns The current DN of the entry. */ - const std::string getDN() const ; + const std::string& getDN() const ; /** * @returns A const pointer to the attributes of the entry. diff --git a/contrib/ldapc++/src/LDAPException.h b/contrib/ldapc++/src/LDAPException.h index be4873a534..09d94f4ab5 100644 --- a/contrib/ldapc++/src/LDAPException.h +++ b/contrib/ldapc++/src/LDAPException.h @@ -22,7 +22,7 @@ class LDAPException{ /** * Constructs a LDAPException-object from the parameters * @param res_code A valid LDAP result code. - * @param err_std::string An addional error message for the error + * @param err_string An addional error message for the error * that happend (optional) */ LDAPException(int res_code, const std::string& err_string=std::string()); diff --git a/contrib/ldapc++/src/LDAPModList.h b/contrib/ldapc++/src/LDAPModList.h index 0edcd9e86e..313808d5dd 100644 --- a/contrib/ldapc++/src/LDAPModList.h +++ b/contrib/ldapc++/src/LDAPModList.h @@ -20,7 +20,7 @@ class LDAPModList{ public : /** - * Constructs an empty std::list. + * Constructs an empty list. */ LDAPModList(); @@ -30,13 +30,13 @@ class LDAPModList{ LDAPModList(const LDAPModList&); /** - * Adds one element to the end of the std::list. + * Adds one element to the end of the list. * @param mod The LDAPModification to add to the std::list. */ void addModification(const LDAPModification &mod); /** - * Translates the std::list to a 0-terminated array of + * Translates the list to a 0-terminated array of * LDAPMod-structures as needed by the C-API */ LDAPMod** toLDAPModArray(); diff --git a/contrib/ldapc++/src/LDAPModifyRequest.cpp b/contrib/ldapc++/src/LDAPModifyRequest.cpp index 579ff8b74f..3d688ca353 100644 --- a/contrib/ldapc++/src/LDAPModifyRequest.cpp +++ b/contrib/ldapc++/src/LDAPModifyRequest.cpp @@ -40,7 +40,9 @@ LDAPModifyRequest::~LDAPModifyRequest(){ "LDAPModifyRequest::~LDAPModifyRequest()" << endl); delete m_modList; // flush this entry from cache. - m_connection->uncache_entry(m_dn); + //m_connection->uncache_entry(m_dn); + // I think we need to do this... (j.costlow) + m_connection->flush_cache(); } LDAPMessageQueue* LDAPModifyRequest::sendRequest(){ diff --git a/contrib/ldapc++/src/LDAPReferenceList.h b/contrib/ldapc++/src/LDAPReferenceList.h index d528b2d65d..0aa5a18219 100644 --- a/contrib/ldapc++/src/LDAPReferenceList.h +++ b/contrib/ldapc++/src/LDAPReferenceList.h @@ -13,7 +13,7 @@ class LDAPSearchReference; typedef std::list RefList; /** - * Container class for storing a std::list of Search References + * Container class for storing a list of Search References * * Used internally only by LDAPSearchResults */ @@ -22,7 +22,7 @@ class LDAPReferenceList{ typedef RefList::const_iterator const_iterator; /** - * Constructs an empty std::list. + * Constructs an empty list. */ LDAPReferenceList(); diff --git a/contrib/ldapc++/src/LDAPReferralException.h b/contrib/ldapc++/src/LDAPReferralException.h index 5ec0d2d4d3..f604f67adc 100644 --- a/contrib/ldapc++/src/LDAPReferralException.h +++ b/contrib/ldapc++/src/LDAPReferralException.h @@ -21,7 +21,7 @@ class LDAPReferralException : public LDAPException{ public : /** - * Creates an object that is initialized with a std::list of URLs + * Creates an object that is initialized with a list of URLs */ LDAPReferralException(const LDAPUrlList& urls); diff --git a/contrib/ldapc++/src/LDAPUrl.h b/contrib/ldapc++/src/LDAPUrl.h index f2522d945a..9314aa09b2 100644 --- a/contrib/ldapc++/src/LDAPUrl.h +++ b/contrib/ldapc++/src/LDAPUrl.h @@ -22,7 +22,7 @@ class LDAPUrl{ public : /** - * Create a new object from a c-std::string that contains a LDAP-Url + * Create a new object from a c-string that contains a LDAP-Url */ LDAPUrl(const char *url); @@ -43,7 +43,7 @@ class LDAPUrl{ int getScope() const; /** - * @return The complete URL as a std::string + * @return The complete URL as a string */ const std::string& getURLString() const; diff --git a/contrib/ldapc++/src/LDAPUrlList.h b/contrib/ldapc++/src/LDAPUrlList.h index 3f905e42a2..1247fc6ad1 100644 --- a/contrib/ldapc++/src/LDAPUrlList.h +++ b/contrib/ldapc++/src/LDAPUrlList.h @@ -19,7 +19,7 @@ class LDAPUrlList{ typedef UrlList::const_iterator const_iterator; /** - * Constructs an empty std::list. + * Constructs an empty list. */ LDAPUrlList(); @@ -32,7 +32,7 @@ class LDAPUrlList{ * For internal use only * * This constructor is used by the library internally to create a - * std::list of URLs from a array of C-std::strings that was return by + * std::list of URLs from a array of C-strings that was return by * the C-API */ LDAPUrlList(char** urls); diff --git a/contrib/ldapc++/src/StringList.h b/contrib/ldapc++/src/StringList.h index 09fe6754d9..caa8ddd147 100644 --- a/contrib/ldapc++/src/StringList.h +++ b/contrib/ldapc++/src/StringList.h @@ -11,7 +11,7 @@ typedef std::list ListType; /** - * Container class to store multiple std::string-objects + * Container class to store multiple string-objects */ class StringList{ private: @@ -21,7 +21,7 @@ class StringList{ typedef ListType::const_iterator const_iterator; /** - * Constructs an empty std::list. + * Constructs an empty list. */ StringList(); @@ -34,7 +34,7 @@ class StringList{ * For internal use only * * This constructor is used by the library internally to create a - * std::list of std::string from a array for c-Strings (char*)thar was + * list of string from a array for c-Strings (char*)thar was * returned by the C-API */ StringList(char** values);