From: Amos Jeffries Date: Mon, 28 Feb 2022 18:03:54 +0000 (+0000) Subject: Improve modularity of IDENT protocol code (#991) X-Git-Tag: SQUID_6_0_1~227 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0b3047784d06d1540cfdc0ea4d753bbe5bf8ff3c;p=thirdparty%2Fsquid.git Improve modularity of IDENT protocol code (#991) Simple changes to further isolate the IDENT code in ident/libident.la and redux the mainInitialize() sequence. Ident::Start() is already checking for and triggering ident_hash initialization. No need to do so in main.cc if there is never any use of IDENT. Removing one unnecessary memory allocation. --- diff --git a/src/ident/Ident.cc b/src/ident/Ident.cc index 5ec7a7fac0..8dccd62e7f 100644 --- a/src/ident/Ident.cc +++ b/src/ident/Ident.cc @@ -275,7 +275,9 @@ Ident::Start(const Comm::ConnectionPointer &conn, IDCB * callback, void *data) assert(static_cast(res) < sizeof(key)); if (!ident_hash) { - Init(); + ident_hash = hash_create((HASHCMP *) strcmp, + hashPrime(Squid_MaxFD / 8), + hash4); } if ((state = (IdentStateData *)hash_lookup(ident_hash, key)) != NULL) { ClientAdd(state, callback, data); @@ -303,18 +305,5 @@ Ident::Start(const Comm::ConnectionPointer &conn, IDCB * callback, void *data) state->connWait.start(connOpener, call); } -void -Ident::Init(void) -{ - if (ident_hash) { - debugs(30, DBG_CRITICAL, "WARNING: Ident already initialized."); - return; - } - - ident_hash = hash_create((HASHCMP *) strcmp, - hashPrime(Squid_MaxFD / 8), - hash4); -} - #endif /* USE_IDENT */ diff --git a/src/ident/Ident.h b/src/ident/Ident.h index ea20314c6f..6f1f048536 100644 --- a/src/ident/Ident.h +++ b/src/ident/Ident.h @@ -22,18 +22,10 @@ namespace Ident /** * Open a connection and request IDENT information from a peer machine. - * Callback will be called whan the lookup is completed. - * Self-registers with a global ident lookup manager, - * will call Ident::Init() itself if the manager has not been initialized already. + * Callback will be called when the lookup is completed. */ void Start(const Comm::ConnectionPointer &conn, IDCB * callback, void *cbdata); -/** - * Initialize IDENT lookup manager. - * Currently a hash list of open ident requests. - */ -void Init(void); - } // namespace Ident #endif /* USE_IDENT */ diff --git a/src/main.cc b/src/main.cc index 61f0df41a2..719517cc82 100644 --- a/src/main.cc +++ b/src/main.cc @@ -50,7 +50,6 @@ #include "icmp/IcmpSquid.h" #include "icmp/net_db.h" #include "ICP.h" -#include "ident/Ident.h" #include "Instance.h" #include "ip/tools.h" #include "ipc/Coordinator.h" @@ -1208,10 +1207,6 @@ mainInitialize(void) icapLogOpen(); #endif -#if USE_IDENT - Ident::Init(); -#endif - #if SQUID_SNMP snmpInit();