diff --git a/directory/xpcom/TODO.txt b/directory/xpcom/TODO.txt index d5713f60b86a..72fec469807f 100644 --- a/directory/xpcom/TODO.txt +++ b/directory/xpcom/TODO.txt @@ -75,9 +75,6 @@ housecleaning error conditions (eg network & data errors). should audit interface boundaries to make sure they do appropriate checking. -* migrate from "#ifdef DEBUG_dmose PR_fprintf(PR_STDERR)" to a more - general logging mechanism (PR_Log) - * does always using this-> for member vars cause inheritance problems? if so, does it matter in an XPCOM world? @@ -114,6 +111,10 @@ rdf datasource (in progress: dmose) * nsILDAPURL (see nsIIOService.idl: extractScheme()) +testing +------- +* see how the browser copes when it does such a big search that the server + only returns partial results and an error. perf ---- diff --git a/directory/xpcom/base/public/nsLDAP.h b/directory/xpcom/base/public/nsLDAP.h index fb939ca48678..c14682992868 100644 --- a/directory/xpcom/base/public/nsLDAP.h +++ b/directory/xpcom/base/public/nsLDAP.h @@ -1,5 +1,6 @@ #include "ldap.h" #include "nsError.h" +#include "nspr.h" #define NS_ERROR_LDAP_OPERATIONS_ERROR \ NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, LDAP_OPERATIONS_ERROR) @@ -12,3 +13,7 @@ #define NS_ERROR_LDAP_NOT_SUPPORTED \ NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, LDAP_NOT_SUPPORTED) + +#ifdef DEBUG +extern PRLogModuleInfo *gLDAPLogModule; // defn in nsLDAPProtocolModule.cpp +#endif diff --git a/directory/xpcom/base/src/nsLDAPChannel.cpp b/directory/xpcom/base/src/nsLDAPChannel.cpp index 26d26d00148b..ee6b129f753b 100644 --- a/directory/xpcom/base/src/nsLDAPChannel.cpp +++ b/directory/xpcom/base/src/nsLDAPChannel.cpp @@ -32,6 +32,7 @@ * GPL. */ +#include "nsLDAP.h" #include "nsLDAPConnection.h" #include "nsLDAPChannel.h" #include "nsString.h" @@ -48,9 +49,6 @@ // #include "nsIEventQueueService.h" -#ifdef DEBUG -#include "nspr.h" -#endif NS_IMPL_THREADSAFE_ISUPPORTS3(nsLDAPChannel, nsIChannel, nsIRequest, nsILDAPMessageListener); @@ -604,13 +602,13 @@ nsLDAPChannel::AsyncRead(nsIStreamListener* aListener, NS_ENSURE_SUCCESS(rv, rv); // kick off a bind operation - // XXXdmose better error handling / passthrough; deal with password // -#ifdef DEBUG_dmose - PR_fprintf(PR_STDERR, "initiating SimpleBind\n"); -#endif + PR_LOG(gLDAPLogModule, PR_LOG_DEBUG, ("initiating SimpleBind\n")); rv = mCurrentOperation->SimpleBind(NULL); if (NS_FAILED(rv)) { + + // XXXdmose better error handling / passthrough; deal with password + // #ifdef DEBUG PR_fprintf(PR_STDERR, "mCurrentOperation->SimpleBind failed. rv=%d\n", rv); @@ -756,9 +754,8 @@ nsLDAPChannel::OnLDAPBind(nsILDAPMessage *aMessage) // XXX what about timeouts? // XXX failure is a reasonable thing; don't assert // -#ifdef DEBUG_dmose - PR_fprintf(PR_STDERR, "bind completed; starting search\n"); -#endif + PR_LOG(gLDAPLogModule, PR_LOG_DEBUG, + ("bind completed; starting search\n")); rv = mCurrentOperation->SearchExt(baseDn, scope, filter, 0, LDAP_NO_LIMIT); NS_ENSURE_SUCCESS(rv,rv); @@ -773,9 +770,7 @@ nsLDAPChannel::OnLDAPSearchResult(nsILDAPMessage *aMessage) PRInt32 errorCode; // the LDAP error code nsresult rv; -#ifdef DEBUG_dmose - PR_fprintf(PR_STDERR, "result returned\n"); -#endif + PR_LOG(gLDAPLogModule, PR_LOG_DEBUG, ("result returned\n")); // XXX should use GetErrorString here? // @@ -816,9 +811,7 @@ nsLDAPChannel::OnLDAPSearchEntry(nsILDAPMessage *aMessage) nsresult rv; char *dn, *attr; -#ifdef DEBUG_dmose - PR_fprintf(PR_STDERR, "entry returned!\n"); -#endif + PR_LOG(gLDAPLogModule, PR_LOG_DEBUG, ("entry returned!\n")); // get the DN // XXX better err handling diff --git a/directory/xpcom/base/src/nsLDAPConnection.cpp b/directory/xpcom/base/src/nsLDAPConnection.cpp index 39d3c659bffd..c845a1f8584a 100644 --- a/directory/xpcom/base/src/nsLDAPConnection.cpp +++ b/directory/xpcom/base/src/nsLDAPConnection.cpp @@ -31,7 +31,7 @@ * GPL. */ -#include "nspr.h" +#include "nsLDAP.h" #include "nsIComponentManager.h" #include "nsLDAPConnection.h" #include "nsLDAPMessage.h" @@ -56,9 +56,7 @@ nsLDAPConnection::~nsLDAPConnection() { int rc; -#ifdef DEBUG_dmose - PR_fprintf(PR_STDERR,"unbinding\n"); -#endif + PR_LOG(gLDAPLogModule, PR_LOG_DEBUG, ("unbinding\n")); rc = ldap_unbind_s(this->mConnectionHandle); if (rc != LDAP_SUCCESS) { @@ -68,9 +66,7 @@ nsLDAPConnection::~nsLDAPConnection() #endif } -#ifdef DEBUG_dmose - PR_fprintf(PR_STDERR,"unbound\n"); -#endif + PR_LOG(gLDAPLogModule, PR_LOG_DEBUG, ("unbound\n")); // XXX can delete fail? // @@ -97,6 +93,17 @@ nsLDAPConnection::Init(const char *aHost, PRInt16 aPort, const char *aBindName) NS_ENSURE_ARG(aHost); NS_ENSURE_ARG(aPort); +#ifdef DEBUG + // initialize logging, if it hasn't been already + // + if (!gLDAPLogModule) { + gLDAPLogModule = PR_NewLogModule("ldap"); + + NS_ABORT_IF_FALSE(gLDAPLogModule, + "failed to initialize LDAP log module"); + } +#endif + // XXXdmose - is a bindname of "" equivalent to a bind name of // NULL (which which means bind anonymously)? if so, we don't // need to go through these contortions. @@ -337,9 +344,8 @@ nsLDAPConnection::Run(void) return NS_ERROR_FAILURE; } -#ifdef DEBUG_dmose - PR_fprintf(PR_STDERR, "nsLDAPConnection::Run() entered\n"); -#endif + PR_LOG(gLDAPLogModule, PR_LOG_DEBUG, + ("nsLDAPConnection::Run() entered\n")); // wait for results // @@ -355,11 +361,11 @@ nsLDAPConnection::Run(void) switch (returnCode) { case 0: // timeout + // the connection may not exist yet. sleep for a while // and try again -#ifdef DEBUG_dmose - PR_fprintf(PR_STDERR, "ldap_result() timed out.\n"); -#endif + PR_LOG(gLDAPLogModule, PR_LOG_WARNING, + ("ldap_result() timed out.\n")); PR_Sleep(2000); continue; @@ -421,9 +427,7 @@ nsLDAPConnection::InvokeMessageCallback(LDAPMessage *aMsgHandle, nsCOMPtr operation; nsCOMPtr listener; -#ifdef DEBUG_dmose - PR_fprintf(PR_STDERR, "InvokeMessageCallback entered\n"); -#endif + PR_LOG(gLDAPLogModule, PR_LOG_DEBUG, ("InvokeMessageCallback entered\n")); // get the message id corresponding to this operation // @@ -447,10 +451,10 @@ nsLDAPConnection::InvokeMessageCallback(LDAPMessage *aMsgHandle, // nsISupports *data = mPendingOperations->Get(key); if (data == nsnull) { -#ifdef DEBUG_dmose - PR_fprintf(PR_STDERR, "InvokeMessageCallback(): couldn't find " - "nsILDAPOperation corresponding to this message id\n"); -#endif + + PR_LOG(gLDAPLogModule, PR_LOG_WARNING, + ("InvokeMessageCallback(): couldn't find " + "nsILDAPOperation corresponding to this message id\n")); delete key; // this may well be ok, since it could just mean that the operation diff --git a/directory/xpcom/base/src/nsLDAPConnection.h b/directory/xpcom/base/src/nsLDAPConnection.h index ae65cca6c96c..e5518507e7ae 100644 --- a/directory/xpcom/base/src/nsLDAPConnection.h +++ b/directory/xpcom/base/src/nsLDAPConnection.h @@ -42,6 +42,7 @@ #include "nsCOMPtr.h" #include "nsILDAPMessageListener.h" #include "nsHashtable.h" +#include "nspr.h" // 0d871e30-1dd2-11b2-8ea9-831778c78e93 // diff --git a/directory/xpcom/base/src/nsLDAPProtocolModule.cpp b/directory/xpcom/base/src/nsLDAPProtocolModule.cpp index b2a91ecac483..b2026f6f69bf 100644 --- a/directory/xpcom/base/src/nsLDAPProtocolModule.cpp +++ b/directory/xpcom/base/src/nsLDAPProtocolModule.cpp @@ -71,3 +71,7 @@ static nsModuleComponentInfo components[] = // implement the NSGetModule() exported function // NS_IMPL_NSGETMODULE("nsLDAPProtocolModule", components); + +#ifdef DEBUG +PRLogModuleInfo *gLDAPLogModule = 0; +#endif diff --git a/directory/xpcom/base/src/nsLDAPService.cpp b/directory/xpcom/base/src/nsLDAPService.cpp index 3b8f186c6346..05d95d03692e 100644 --- a/directory/xpcom/base/src/nsLDAPService.cpp +++ b/directory/xpcom/base/src/nsLDAPService.cpp @@ -31,11 +31,9 @@ * GPL. */ +#include "nsLDAP.h" #include "nsLDAPService.h" -#ifdef DEBUG_dmose -#include "nspr.h" -#endif // constructor // @@ -60,10 +58,6 @@ nsLDAPService::Init(void) { nsresult rv; -#ifdef DEBUG_dmose - PR_fprintf(PR_STDERR, "nsLDAPService::Init() entered!\n"); -#endif - NS_ASSERTION(!mThread, "nsLDAPService already initialized!"); rv = NS_NewThread(getter_AddRefs(mThread), @@ -78,9 +72,7 @@ nsLDAPService::Init(void) NS_IMETHODIMP nsLDAPService::Run(void) { -#ifdef DEBUG_dmose - PR_fprintf(PR_STDERR, "nsLDAPService::Run() entered!\n"); -#endif + PR_LOG(gLDAPLogModule, PR_LOG_DEBUG, ("nsLDAPService::Run() entered\n")); // XXX - should use mThreadRunning here //