debug only: warn when stacks of event queues get surprisingly deep. should speed future attempts to debug problems like bug 206947. r=brendan

This commit is contained in:
danm-moz%comcast.net 2003-08-05 00:01:20 +00:00
parent c20da37f7d
commit 579f5d88fb

View File

@ -47,6 +47,10 @@
#include "prlog.h"
#ifdef NS_DEBUG
#include "prprf.h"
#endif
#if defined(PR_LOGGING) && defined(DEBUG_danm)
/* found these logs useful in conjunction with netlibStreamEvent logging
from netwerk. */
@ -509,6 +513,21 @@ nsEventQueueImpl::AppendQueue(nsIEventQueue *aQueue)
*/
rv = NS_ERROR_NO_INTERFACE;
#ifdef NS_DEBUG
int depth = 0;
nsEventQueueImpl *next = this;
while (next && depth < 100) {
next = NS_STATIC_CAST(nsEventQueueImpl *, next->mYoungerQueue);
++depth;
}
if (depth > 5) {
char warning[80];
PR_snprintf(warning, sizeof(warning),
"event queue chain length is %d. this is almost certainly a leak.", depth);
NS_WARNING(warning);
}
#endif
// (be careful doing this outside nsEventQueueService's mEventQMonitor)
GetYoungest(getter_AddRefs(end));