]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Improve modularity of IDENT protocol code (#991)
authorAmos Jeffries <yadij@users.noreply.github.com>
Mon, 28 Feb 2022 18:03:54 +0000 (18:03 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Wed, 2 Mar 2022 02:15:19 +0000 (02:15 +0000)
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.

src/ident/Ident.cc
src/ident/Ident.h
src/main.cc

index 5ec7a7fac051094f8f27f57856a780489a13fac4..8dccd62e7f164302eedc4048bdab12eef69a95e8 100644 (file)
@@ -275,7 +275,9 @@ Ident::Start(const Comm::ConnectionPointer &conn, IDCB * callback, void *data)
     assert(static_cast<unsigned int>(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 */
 
index ea20314c6f3aa6d822b7097871691da822da2fac..6f1f048536ee7cc27d7a0f9b750507a1d6e6ab24 100644 (file)
@@ -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 */
index 61f0df41a2b22b9a098a0f45f9730c567cd85776..719517cc821dd7e367a54ed66743ef286ae5c081 100644 (file)
@@ -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();