From: Wilfried Goesgens Date: Mon, 25 Mar 2013 13:56:49 +0000 (+0100) Subject: NTT: add a debug facility to dump all currently locked peers X-Git-Tag: v8.20~73 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=08ee2a599ae6442be97335bc38f40aeb3bc2e365 NTT: add a debug facility to dump all currently locked peers --- diff --git a/citadel/nttlist.c b/citadel/nttlist.c index 5831d4a7d..a38cd35db 100644 --- a/citadel/nttlist.c +++ b/citadel/nttlist.c @@ -23,6 +23,7 @@ * Network maps: evaluate other nodes * *-----------------------------------------------------------------------------*/ int NTTDebugEnabled = 0; +int NTTDumpEnabled = 0; /* * network_talking_to() -- concurrency checker @@ -67,6 +68,29 @@ int CtdlNetworkTalkingTo(const char *nodename, long len, int operation) break; } + if (NTTDumpEnabled) + { + HashPos *It; + StrBuf *NTTDump; + long len; + const char *Key; + void *v; + NTTDump = NewStrBuf (); + + It = GetNewHashPos(nttlist, 0); + while (GetNextHashPos(nttlist, It, &len, &Key, &v)) + { + if (StrLength(NTTDump) > 0) + StrBufAppendBufPlain(NTTDump, HKEY("|"), 0); + StrBufAppendBuf(NTTDump, (StrBuf*) v, 0); + } + DeleteHashPos(&It); + + syslog(LOG_DEBUG, "nttlist: Dump: [%d] <%s>\n", + GetCount(nttlist), + ChrPtr(NTTDump)); + FreeStrBuf(&NTTDump); + } end_critical_section(S_NTTLIST); return(retval); } @@ -88,6 +112,11 @@ void SetNTTDebugEnabled(const int n) NTTDebugEnabled = n; } +void SetNTTDumpEnabled(const int n) +{ + NTTDumpEnabled = n; +} + /* @@ -98,6 +127,7 @@ CTDL_MODULE_INIT(nttlist) if (!threading) { CtdlRegisterDebugFlagHook(HKEY("networktalkingto"), SetNTTDebugEnabled, &NTTDebugEnabled); + CtdlRegisterDebugFlagHook(HKEY("dumpnetworktalkingto"), SetNTTDumpEnabled, &NTTDumpEnabled); CtdlRegisterCleanupHook(cleanup_nttlist); }