---------------------
PatchSet 2793 
Date: 2001/08/20 13:46:41
Author: rbcollins
Branch: ntlm
Tag: (none) 
Log:
paranoid debugging

Members: 
	src/auth/ntlm/auth_ntlm.c:1.1.10.14.2.40->1.1.10.14.2.41 

Index: squid/src/auth/ntlm/auth_ntlm.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/auth/ntlm/auth_ntlm.c,v
retrieving revision 1.1.10.14.2.40
retrieving revision 1.1.10.14.2.41
diff -u -r1.1.10.14.2.40 -r1.1.10.14.2.41
--- squid/src/auth/ntlm/auth_ntlm.c	20 Aug 2001 11:53:04 -0000	1.1.10.14.2.40
+++ squid/src/auth/ntlm/auth_ntlm.c	20 Aug 2001 13:46:41 -0000	1.1.10.14.2.41
@@ -378,6 +378,7 @@
     if (ntlm_request->authserver != NULL && ntlm_request->authserver_deferred) {
 	debug(29, 9) ("authenticateNTLMRequestFree: releasing server '%d'\n", ntlm_request->authserver);
 	helperStatefulReleaseServer(ntlm_request->authserver);
+debug(29,1)("ntr %x released %x\n",ntlm_request,ntlm_request->authserver);
 	ntlm_request->authserver = NULL;
     }
     memPoolFree(ntlm_request_pool, ntlm_request);
@@ -571,6 +572,7 @@
 		assert((ntlm_user != NULL) && (ntlm_request != NULL));
 		result = S_HELPER_RELEASE;	/*some error has occured. no more requests for 
 						 * this helper */
+		assert (ntlm_request->authserver ? ntlm_request->authserver == lastserver : 1);
 		helperstate = helperStatefulServerGetData(ntlm_request->authserver);
 		ntlm_request->authserver = NULL;
 		if (ntlm_request->auth_state == AUTHENTICATE_STATE_NEGOTIATE) {
@@ -587,6 +589,8 @@
 		    cbdataUnlock(r->data);
 		    authenticateStateFree(r);
 		    debug(29, 9) ("NTLM HandleReply, telling stateful helper : %d\n", result);
+assert (result == S_HELPER_RELEASE);
+debug(29,1)("au %x released %x\n",auth_user_request,lastserver);
 		    return result;
 		} else {
 		    /* the helper broke on a KK */
@@ -613,6 +617,7 @@
 		/* restart the authentication process */
 		ntlm_request->auth_state = AUTHENTICATE_STATE_NONE;
 		auth_user->flags.credentials_ok = 3;	/* cannot process */
+		assert (ntlm_request->authserver ? ntlm_request->authserver == lastserver : 1);
 		ntlm_request->authserver = NULL;
 	    }
 	} else {
@@ -622,10 +627,22 @@
     } else {
 	debug(29, 1) ("AuthenticateNTLMHandleReply: invalid callback data. Releasing helper '%d'.\n", lastserver);
 	result = S_HELPER_RELEASE;
+debug(29,1)("au %x released %x\n",NULL,lastserver);
     }
     cbdataUnlock(r->data);
     authenticateStateFree(r);
     debug(29, 9) ("NTLM HandleReply, telling stateful helper : %d\n", result);
+switch (result)
+{
+  case S_HELPER_RELEASE:
+debug(29,1)("au %x released %x\n",auth_user_request,lastserver);
+break;
+  case S_HELPER_DEFER:
+debug(29,1)("au %x deferred %x\n",auth_user_request,lastserver);
+break;
+  default:
+break;
+}
     return result;
 }
 
@@ -730,14 +747,17 @@
 	 * 3: tell it to get a challenge, or give ntlmauthdone the challenge
 	 */
 	server = helperStatefulDefer(ntlmauthenticators);
+debug(29,1)("au %x deferred %x\n",auth_user_request,server);	
 	helperstate = server ? helperStatefulServerGetData(server) : NULL;
 	while ((server != NULL) && authenticateNTLMChangeChallenge_p(helperstate)) {
 	    /* flag this helper for challenge changing */
 	    helperstate->starve = 1;
 	    /* and release the deferred request */
 	    helperStatefulReleaseServer(server);
+debug(29,1)("au %x released %x\n",auth_user_request,server);
 	    /* Get another deferrable server */
 	    server = helperStatefulDefer(ntlmauthenticators);
+debug(29,1)("au %x deferred %x\n",auth_user_request,server);
 	    helperstate = server ? helperStatefulServerGetData(server) : NULL;
 	}
 	if (server == NULL)
@@ -756,10 +776,12 @@
 	    r->auth_user_request = auth_user_request;
 	    if (server == NULL) {
 		helperStatefulSubmit(ntlmauthenticators, NULL, authenticateNTLMHandleplaceholder, r, NULL);
+debug(29,1)("au %x submitted to %x\n",auth_user_request,server);
 	    } else {
 		/* Server with invalid challenge */
 		snprintf(buf, 8192, "YR\n");
 		helperStatefulSubmit(ntlmauthenticators, buf, authenticateNTLMHandleReply, r, ntlm_request->authserver);
+debug(29,1)("au %x submitted to %x\n",auth_user_request,server);
 	    }
 	} else {
 	    /* (server != NULL and we have a valid challenge) */
@@ -786,6 +808,7 @@
 	/* getting rid of deferred request status */
 	ntlm_request->authserver_deferred = 0;
 	helperStatefulSubmit(ntlmauthenticators, buf, authenticateNTLMHandleReply, r, ntlm_request->authserver);
+debug(29,1)("au %x submitted to %x\n",auth_user_request,ntlm_request->authserver);
 	debug(29, 9) ("authenticateNTLMstart: finished\n");
 	break;
     default:
@@ -839,6 +862,7 @@
     ntlm_request = auth_user_request->scheme_data;
     debug(29, 9) ("authenticateNTLMReleaseServer: releasing server '%d'\n", ntlm_request->authserver);
     helperStatefulReleaseServer(ntlm_request->authserver);
+debug(29,1)("au %x released %x\n",auth_user_request,ntlm_request->authserver);
     ntlm_request->authserver = NULL;
 }
 
