From 64b4daa656d5d7d20dba063d158eb7678decafd4 Mon Sep 17 00:00:00 2001 From: "danm-moz%comcast.net" Date: Tue, 5 Aug 2003 00:01:20 +0000 Subject: [PATCH] debug only: warn when stacks of event queues get surprisingly deep. should speed future attempts to debug problems like bug 206947. r=brendan git-svn-id: svn://10.0.0.236/trunk@145575 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/xpcom/threads/nsEventQueue.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/mozilla/xpcom/threads/nsEventQueue.cpp b/mozilla/xpcom/threads/nsEventQueue.cpp index 86ba9e5049d..1965f3fee6b 100644 --- a/mozilla/xpcom/threads/nsEventQueue.cpp +++ b/mozilla/xpcom/threads/nsEventQueue.cpp @@ -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));