]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/ident/AclIdent.cc
SourceFormat Enforcement
[thirdparty/squid.git] / src / ident / AclIdent.cc
index 47a6885ecefac0264c9ba8d3bc2c58d22d9a18fd..34c00fdc30f3f8a70cb88dfb32c346932944ddc3 100644 (file)
@@ -43,6 +43,7 @@
 #include "acl/UserData.h"
 #include "client_side.h"
 #include "comm/Connection.h"
+#include "globals.h"
 #include "ident/AclIdent.h"
 #include "ident/Ident.h"
 
@@ -89,10 +90,14 @@ ACLIdent::match(ACLChecklist *cl)
         return data->match(checklist->rfc931);
     } else if (checklist->conn() != NULL && checklist->conn()->clientConnection != NULL && checklist->conn()->clientConnection->rfc931[0]) {
         return data->match(checklist->conn()->clientConnection->rfc931);
-    } else {
+    } else if (checklist->conn() != NULL && Comm::IsConnOpen(checklist->conn()->clientConnection)) {
         debugs(28, 3, HERE << "switching to ident lookup state");
         checklist->changeState(IdentLookup::Instance());
         return 0;
+    } else {
+        debugs(28, DBG_IMPORTANT, HERE << "Can't start ident lookup. No client connection" );
+        checklist->markFinished(ACCESS_DUNNO, "cannot start ident lookup");
+        return -1;
     }
 }
 
@@ -114,7 +119,6 @@ ACLIdent::clone() const
     return new ACLIdent(*this);
 }
 
-
 IdentLookup IdentLookup::instance_;
 
 IdentLookup *
@@ -127,15 +131,12 @@ void
 IdentLookup::checkForAsync(ACLChecklist *cl)const
 {
     ACLFilledChecklist *checklist = Filled(cl);
-    if (checklist->conn() != NULL && Comm::IsConnOpen(checklist->conn()->clientConnection)) {
-        debugs(28, 3, HERE << "Doing ident lookup" );
-        checklist->asyncInProgress(true);
-        Ident::Start(checklist->conn()->clientConnection, LookupDone, checklist);
-    } else {
-        debugs(28, DBG_IMPORTANT, "IdentLookup::checkForAsync: Can't start ident lookup. No client connection" );
-        checklist->currentAnswer(ACCESS_DENIED);
-        checklist->markFinished();
-    }
+    const ConnStateData *conn = checklist->conn();
+    // check that ACLIdent::match() tested this lookup precondition
+    assert(conn && Comm::IsConnOpen(conn->clientConnection));
+    debugs(28, 3, HERE << "Doing ident lookup" );
+    checklist->asyncInProgress(true);
+    Ident::Start(checklist->conn()->clientConnection, LookupDone, checklist);
 }
 
 void