2 * This module handles shared rooms, inter-Citadel mail, and outbound
3 * mailing list processing.
5 * Copyright (c) 2000-2012 by the citadel.org team
7 * This program is open source software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License, version 3.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
18 #include <libcitadel.h>
19 #include "ctdl_module.h"
20 #include "serv_extensions.h"
22 /*-----------------------------------------------------------------------------*
23 * Network maps: evaluate other nodes *
24 *-----------------------------------------------------------------------------*/
25 int NTTDebugEnabled = 0;
28 * network_talking_to() -- concurrency checker
30 static HashList *nttlist = NULL;
31 int CtdlNetworkTalkingTo(const char *nodename, long len, int operation)
38 begin_critical_section(S_NTTLIST);
44 nttlist = NewHash(1, NULL);
45 Put(nttlist, nodename, len, NewStrBufPlain(nodename, len), HFreeStrBuf);
46 if (NTTDebugEnabled) syslog(LOG_DEBUG, "nttlist: added <%s>\n", nodename);
49 if ((nttlist == NULL) ||
50 (GetCount(nttlist) == 0))
52 Pos = GetNewHashPos(nttlist, 1);
53 if (GetHashPosFromKey (nttlist, nodename, len, Pos))
54 DeleteEntryFromHash(nttlist, Pos);
56 if (NTTDebugEnabled) syslog(LOG_DEBUG, "nttlist: removed <%s>\n", nodename);
61 if ((nttlist == NULL) ||
62 (GetCount(nttlist) == 0))
64 if (GetHash(nttlist, nodename, len, &vdata))
66 if (NTTDebugEnabled) syslog(LOG_DEBUG, "nttlist: have [%d] <%s>\n", retval, nodename);
70 end_critical_section(S_NTTLIST);
74 void cleanup_nttlist(void)
76 begin_critical_section(S_NTTLIST);
78 end_critical_section(S_NTTLIST);
86 void SetNTTDebugEnabled(const int n)
96 CTDL_MODULE_INIT(nttlist)
100 CtdlRegisterDebugFlagHook(HKEY("networktalkingto"), SetNTTDebugEnabled, &NTTDebugEnabled);
102 CtdlRegisterCleanupHook(cleanup_nttlist);