Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

src: Add the location of the last lock to help debugging.



details:   https://anonhg.NetBSD.org/src/rev/a05b39d6ac6c
branches:  trunk
changeset: 318073:a05b39d6ac6c
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Apr 11 18:33:48 2018 +0000
description:
Add the location of the last lock to help debugging.

diffstat:

 external/apache2/mDNSResponder/dist/mDNSCore/DNSCommon.c       |  19 +++++----
 external/apache2/mDNSResponder/dist/mDNSCore/DNSCommon.h       |   8 ++--
 external/apache2/mDNSResponder/dist/mDNSCore/mDNSEmbeddedAPI.h |   2 +
 3 files changed, 17 insertions(+), 12 deletions(-)

diffs (114 lines):

diff -r a1c78a9c4746 -r a05b39d6ac6c external/apache2/mDNSResponder/dist/mDNSCore/DNSCommon.c
--- a/external/apache2/mDNSResponder/dist/mDNSCore/DNSCommon.c  Wed Apr 11 18:33:21 2018 +0000
+++ b/external/apache2/mDNSResponder/dist/mDNSCore/DNSCommon.c  Wed Apr 11 18:33:48 2018 +0000
@@ -3838,7 +3838,7 @@
 #pragma mark - RR List Management & Task Management
 #endif
 
-mDNSexport void mDNS_Lock_(mDNS *const m, const char * const functionname)
+mDNSexport void mDNS_Lock_(mDNS *const m, const char * const functionname, int lineno)
 {
     // MUST grab the platform lock FIRST!
     mDNSPlatformLock(m);
@@ -3848,20 +3848,20 @@
     // If that client callback does mDNS API calls, mDNS_reentrancy and mDNS_busy will both be one
     // If mDNS_busy != mDNS_reentrancy that's a bad sign
     if (m->mDNS_busy != m->mDNS_reentrancy)
-        LogFatalError("%s: mDNS_Lock: Locking failure! mDNS_busy (%ld) != mDNS_reentrancy (%ld)", functionname, m->mDNS_busy, m->mDNS_reentrancy);
+        LogFatalError("%s,%d: mDNS_Lock: Locking failure! mDNS_busy (%ld) != mDNS_reentrancy (%ld) (last %s,%d)", functionname, lineno, m->mDNS_busy, m->mDNS_reentrancy, m->mDNS_Lock_functionname, 
m->mDNS_Lock_lineno);
 
     // If this is an initial entry into the mDNSCore code, set m->timenow
     // else, if this is a re-entrant entry into the mDNSCore code, m->timenow should already be set
     if (m->mDNS_busy == 0)
     {
         if (m->timenow)
-            LogMsg("%s: mDNS_Lock: m->timenow already set (%ld/%ld)", functionname, m->timenow, mDNS_TimeNow_NoLock(m));
+            LogMsg("%s,%d: mDNS_Lock: m->timenow already set (%ld/%ld)", functionname, lineno, m->timenow, mDNS_TimeNow_NoLock(m));
         m->timenow = mDNS_TimeNow_NoLock(m);
         if (m->timenow == 0) m->timenow = 1;
     }
     else if (m->timenow == 0)
     {
-        LogMsg("%s: mDNS_Lock: m->mDNS_busy is %ld but m->timenow not set", functionname, m->mDNS_busy);
+        LogMsg("%s,%d: mDNS_Lock: m->mDNS_busy is %ld but m->timenow not set", functionname, lineno, m->mDNS_busy);
         m->timenow = mDNS_TimeNow_NoLock(m);
         if (m->timenow == 0) m->timenow = 1;
     }
@@ -3869,13 +3869,15 @@
     if (m->timenow_last - m->timenow > 0)
     {
         m->timenow_adjust += m->timenow_last - m->timenow;
-        LogMsg("%s: mDNSPlatformRawTime went backwards by %ld ticks; setting correction factor to %ld", functionname, m->timenow_last - m->timenow, m->timenow_adjust);
+        LogMsg("%s,%d: mDNSPlatformRawTime went backwards by %ld ticks; setting correction factor to %ld", functionname, lineno, m->timenow_last - m->timenow, m->timenow_adjust);
         m->timenow = m->timenow_last;
     }
     m->timenow_last = m->timenow;
 
     // Increment mDNS_busy so we'll recognise re-entrant calls
     m->mDNS_busy++;
+    m->mDNS_Lock_functionname = functionname;
+    m->mDNS_Lock_lineno = lineno;
 }
 
 mDNSlocal AuthRecord *AnyLocalRecordReady(const mDNS *const m)
@@ -4011,20 +4013,21 @@
     mDNS_Unlock(m);
 }
 
-mDNSexport void mDNS_Unlock_(mDNS *const m, const char *const functionname)
+mDNSexport void mDNS_Unlock_(mDNS *const m, const char *const functionname, int lineno)
 {
     // Decrement mDNS_busy
     m->mDNS_busy--;
 
     // Check for locking failures
     if (m->mDNS_busy != m->mDNS_reentrancy)
-        LogFatalError("%s: mDNS_Unlock: Locking failure! mDNS_busy (%ld) != mDNS_reentrancy (%ld)", functionname, m->mDNS_busy, m->mDNS_reentrancy);
+        LogFatalError("%s,%d: mDNS_Unlock: Locking failure! mDNS_busy (%ld) != mDNS_reentrancy (%ld) (last %s,%d)", functionname, lineno, m->mDNS_busy,
+           m->mDNS_reentrancy, m->mDNS_Lock_functionname, m->mDNS_Lock_lineno);
 
     // If this is a final exit from the mDNSCore code, set m->NextScheduledEvent and clear m->timenow
     if (m->mDNS_busy == 0)
     {
         m->NextScheduledEvent = GetNextScheduledEvent(m);
-        if (m->timenow == 0) LogMsg("%s: mDNS_Unlock: ERROR! m->timenow aready zero", functionname);
+        if (m->timenow == 0) LogMsg("%s,%d: mDNS_Unlock: ERROR! m->timenow aready zero", functionname, lineno);
         m->timenow = 0;
     }
 
diff -r a1c78a9c4746 -r a05b39d6ac6c external/apache2/mDNSResponder/dist/mDNSCore/DNSCommon.h
--- a/external/apache2/mDNSResponder/dist/mDNSCore/DNSCommon.h  Wed Apr 11 18:33:21 2018 +0000
+++ b/external/apache2/mDNSResponder/dist/mDNSCore/DNSCommon.h  Wed Apr 11 18:33:48 2018 +0000
@@ -288,16 +288,16 @@
 #endif
 
 extern void ShowTaskSchedulingError(mDNS *const m);
-extern void mDNS_Lock_(mDNS *const m, const char * const functionname);
-extern void mDNS_Unlock_(mDNS *const m, const char * const functionname);
+extern void mDNS_Lock_(mDNS *const m, const char * const functionname, int lineno);
+extern void mDNS_Unlock_(mDNS *const m, const char * const functionname, int lineno);
 
 #if defined(_WIN32)
  #define __func__ __FUNCTION__
 #endif
 
-#define mDNS_Lock(X) mDNS_Lock_((X), __func__)
+#define mDNS_Lock(X) mDNS_Lock_((X), __func__, __LINE__)
 
-#define mDNS_Unlock(X) mDNS_Unlock_((X), __func__)
+#define mDNS_Unlock(X) mDNS_Unlock_((X), __func__, __LINE__)
 
 #define mDNS_CheckLock(X) \
     if ((X)->mDNS_busy != (X)->mDNS_reentrancy+1) LogMsg("%s: Lock not held! mDNS_busy (%ld) mDNS_reentrancy (%ld)", __func__, (X)->mDNS_busy, (X)->mDNS_reentrancy)
diff -r a1c78a9c4746 -r a05b39d6ac6c external/apache2/mDNSResponder/dist/mDNSCore/mDNSEmbeddedAPI.h
--- a/external/apache2/mDNSResponder/dist/mDNSCore/mDNSEmbeddedAPI.h    Wed Apr 11 18:33:21 2018 +0000
+++ b/external/apache2/mDNSResponder/dist/mDNSCore/mDNSEmbeddedAPI.h    Wed Apr 11 18:33:48 2018 +0000
@@ -2319,6 +2319,8 @@
     // For debugging: To catch and report locking failures
     mDNSu32 mDNS_busy;                  // Incremented between mDNS_Lock/mDNS_Unlock section
     mDNSu32 mDNS_reentrancy;            // Incremented when calling a client callback
+    const char *mDNS_Lock_functionname;                // Where was the last lock taken
+    int        mDNS_Lock_lineno;                               // and line number:
     mDNSu8 lock_rrcache;                // For debugging: Set at times when these lists may not be modified
     mDNSu8 lock_Questions;
     mDNSu8 lock_Records;



Home | Main Index | Thread Index | Old Index