--------------------- PatchSet 698 Date: 2000/10/23 09:51:07 Author: rbcollins Branch: ntlm Tag: (none) Log: working multiplexing ntlm auth code Members: src/authenticate.c:1.1.1.3.12.14->1.1.1.3.12.15 src/enums.h:1.1.1.3.12.12->1.1.1.3.12.13 src/helper.c:1.1.1.3.12.11->1.1.1.3.12.12 src/structs.h:1.1.1.3.4.1.2.21->1.1.1.3.4.1.2.22 Index: squid/src/authenticate.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/authenticate.c,v retrieving revision 1.1.1.3.12.14 retrieving revision 1.1.1.3.12.15 diff -u -r1.1.1.3.12.14 -r1.1.1.3.12.15 --- squid/src/authenticate.c 15 Oct 2000 06:06:38 -0000 1.1.1.3.12.14 +++ squid/src/authenticate.c 23 Oct 2000 09:51:07 -0000 1.1.1.3.12.15 @@ -1,6 +1,6 @@ /* - * $Id: authenticate.c,v 1.1.1.3.12.14 2000/10/15 06:06:38 rbcollins Exp $ + * $Id: authenticate.c,v 1.1.1.3.12.15 2000/10/23 09:51:07 rbcollins Exp $ * * DEBUG: section 29 Authenticator * AUTHOR: Duane Wessels @@ -102,7 +102,10 @@ if (reply) { if (strncasecmp(reply, "CH ", 3) == 0) { reply += 3; +#if 0 result=S_HELPER_RESERVE; +#endif + result=S_HELPER_DEFER; nextserver=lastserver; debug(29,4)("authenticateNTLMHandleReply: helper '%d'\n",lastserver); } Index: squid/src/enums.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/enums.h,v retrieving revision 1.1.1.3.12.12 retrieving revision 1.1.1.3.12.13 diff -u -r1.1.1.3.12.12 -r1.1.1.3.12.13 --- squid/src/enums.h 18 Oct 2000 04:21:13 -0000 1.1.1.3.12.12 +++ squid/src/enums.h 23 Oct 2000 09:51:07 -0000 1.1.1.3.12.13 @@ -1,6 +1,6 @@ /* - * $Id: enums.h,v 1.1.1.3.12.12 2000/10/18 04:21:13 hno Exp $ + * $Id: enums.h,v 1.1.1.3.12.13 2000/10/23 09:51:07 rbcollins Exp $ * * * SQUID Internet Object Cache http://squid.nlanr.net/Squid/ @@ -515,15 +515,24 @@ AUTHENTICATE_STATE_RESPONSE, AUTHENTICATE_STATE_DONE #endif -} auth_state_t; +} auth_state_t; /* connection level auth state */ /* stateful helper callback response codes */ typedef enum { S_HELPER_UNKNOWN, S_HELPER_RESERVE, - S_HELPER_RELEASE + S_HELPER_RELEASE, + S_HELPER_DEFER } stateful_helper_callback_t; +/* stateful helper reservation info */ +typedef enum { + S_HELPER_FREE, /* available for requests */ + S_HELPER_RESERVED, /* in a reserved state - no active request, but state data in the helper shouldn't be disturbed */ + S_HELPER_DEFERRED /* available for requests, and at least one more will come from a previous caller with the server pointer */ +} stateful_helper_reserve_t; + + #if SQUID_SNMP enum { SNMP_C_VIEW, Index: squid/src/helper.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/helper.c,v retrieving revision 1.1.1.3.12.11 retrieving revision 1.1.1.3.12.12 diff -u -r1.1.1.3.12.11 -r1.1.1.3.12.12 --- squid/src/helper.c 23 Oct 2000 07:26:57 -0000 1.1.1.3.12.11 +++ squid/src/helper.c 23 Oct 2000 09:51:07 -0000 1.1.1.3.12.12 @@ -1,6 +1,6 @@ /* - * $Id: helper.c,v 1.1.1.3.12.11 2000/10/23 07:26:57 rbcollins Exp $ + * $Id: helper.c,v 1.1.1.3.12.12 2000/10/23 09:51:07 rbcollins Exp $ * * DEBUG: section 29 Helper process maintenance * AUTHOR: Harvest Derived? @@ -55,7 +55,8 @@ static void helperStatefulRequestFree(helper_stateful_request * r); static void StatefulEnqueue(statefulhelper * hlp, helper_stateful_request * r); static helper_stateful_request * StatefulServerDequeue(helper_stateful_server * srv); - +static void StatefulServerEnqueue(helper_stateful_server * srv, helper_stateful_request * r); +static void helperStatefulServerKickQueue(helper_stateful_server * srv); void helperOpenServers(helper * hlp) @@ -183,7 +184,7 @@ srv = memAllocate(MEM_HELPER_STATEFUL_SERVER); cbdataAdd(srv, memFree, MEM_HELPER_STATEFUL_SERVER); srv->flags.alive = 1; - srv->flags.reserved = 0; + srv->flags.reserved = S_HELPER_FREE; srv->index = k; srv->rfd = rfd; srv->wfd = wfd; @@ -269,7 +270,7 @@ void helperStatefulReset(helper_stateful_server * srv) /* puts this helper back in the queue. the calling app is required to - * manage the state in the helper + * manage the state in the helper. */ { statefulhelper * hlp = srv->parent; @@ -283,11 +284,16 @@ srv->offset = 0; helperStatefulRequestFree(r); srv->request = NULL; - } - helperKickQueue(hlp); + } debug(29,1)("helperStatefulReset reset helper %s #%d\n",hlp->id_name,srv->index+1); srv->flags.busy = 0; - srv->flags.reserved=0; + if (srv->queue.head){ + srv->flags.reserved=S_HELPER_DEFERRED; + helperStatefulServerKickQueue(srv); + }else{ + srv->flags.reserved=S_HELPER_FREE; + helperStatefulKickQueue(hlp); + } } void @@ -372,7 +378,7 @@ srv->flags.alive ? 'A' : ' ', srv->flags.busy ? 'B' : ' ', srv->flags.closing ? 'C' : ' ', - srv->flags.reserved ? 'R': ' ', + srv->flags.reserved!=S_HELPER_FREE ? 'R': ' ', srv->flags.shutdown ? 'S' : ' ', tt < 0.0 ? 0.0 : tt, (int) srv->offset, @@ -382,6 +388,7 @@ storeAppendPrintf(sentry, " A = ALIVE\n"); storeAppendPrintf(sentry, " B = BUSY\n"); storeAppendPrintf(sentry, " C = CLOSING\n"); + storeAppendPrintf(sentry, " R = RESERVED or DEFERRED\n"); storeAppendPrintf(sentry, " S = SHUTDOWN\n"); } @@ -439,7 +446,7 @@ hlp->id_name, srv->index + 1); continue; } - if (srv->flags.reserved) { + if (srv->flags.reserved!=S_HELPER_FREE) { debug(34, 3) ("helperStatefulShutdown: %s #%d is RESERVED.\n", hlp->id_name, srv->index + 1); continue; @@ -652,13 +659,29 @@ case S_HELPER_UNKNOWN: fatal("helperStatefulHandleRead: either a non-state aware callback was give to the stateful helper routines, or an uninitialised callback response was recieved.\n"); break; - case S_HELPER_RELEASE: - srv->flags.reserved = 0; - debug(29, 5)("StatefulHandleRead: releasing %s #%d\n",hlp->id_name, srv->index+1); + case S_HELPER_RELEASE: /* helper finished with */ + if (!srv->queue.head){ + srv->flags.reserved = S_HELPER_FREE; + debug(29, 5)("StatefulHandleRead: releasing %s #%d\n",hlp->id_name, srv->index+1); + }else{ + srv->flags.reserved = S_HELPER_DEFERRED; + debug(29, 5)("StatefulHandleRead: outstanding deferred requests on %s #%d. reserving for deferred requests.\n",hlp->id_name, srv->index+1); + } + break; + case S_HELPER_RESERVE: /* 'pin' this helper for the caller */ + if (!srv->queue.head){ + srv->flags.reserved = S_HELPER_RESERVED; + debug(29, 5)("StatefulHandleRead: reserving %s #%d\n",hlp->id_name, srv->index+1); + }else{ + fatal("StatefulHandleRead: Callback routine attempted to reserve a stateful helper with deferred requests. This can lead to deadlock.\n"); + } break; - case S_HELPER_RESERVE: - srv->flags.reserved = 1; - debug(29, 5)("StatefulHandleRead: reserving %s #%d\n",hlp->id_name, srv->index+1); + case S_HELPER_DEFER: + /* the helper is still needed, but can + * be used for other requests in the meantime. + */ + srv->flags.reserved = S_HELPER_DEFERRED; + debug(29, 5)("StatefulHandleRead: reserving %s #%d for deferred requests.\n",hlp->id_name, srv->index+1); break; default: fatal("helperStatefulHandleRead: unknown stateful helper callback result.\n"); @@ -823,12 +846,13 @@ srv = n->data; if (srv->flags.busy) continue; - if (srv->flags.reserved) + if (srv->flags.reserved==S_HELPER_RESERVED) continue; if (!srv->flags.alive) continue; return srv; } + debug(29,5)("StatefulGetFirstAvailable: None available.\n"); return NULL; } @@ -871,7 +895,6 @@ helperStatefulRequestFree(r); return; } - /* we keep ourselves busy when we're in a state request. */ debug(29,9)("helperStatefulDispatch busying helper %s #%d\n",hlp->id_name,srv->index+1); srv->flags.busy = 1; srv->request = r; @@ -915,7 +938,7 @@ helperStatefulServerKickQueue(helper_stateful_server * srv) { helper_stateful_request *r; - if (r = StatefulServerDequeue(srv)) + if ((r = StatefulServerDequeue(srv))) helperStatefulDispatch(srv, r); } Index: squid/src/structs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/structs.h,v retrieving revision 1.1.1.3.4.1.2.21 retrieving revision 1.1.1.3.4.1.2.22 diff -u -r1.1.1.3.4.1.2.21 -r1.1.1.3.4.1.2.22 --- squid/src/structs.h 23 Oct 2000 07:26:57 -0000 1.1.1.3.4.1.2.21 +++ squid/src/structs.h 23 Oct 2000 09:51:07 -0000 1.1.1.3.4.1.2.22 @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.1.1.3.4.1.2.21 2000/10/23 07:26:57 rbcollins Exp $ + * $Id: structs.h,v 1.1.1.3.4.1.2.22 2000/10/23 09:51:07 rbcollins Exp $ * * * SQUID Internet Object Cache http://squid.nlanr.net/Squid/ @@ -1895,7 +1895,7 @@ unsigned int busy:1; unsigned int closing:1; unsigned int shutdown:1; - unsigned int reserved:1; + stateful_helper_reserve_t reserved:2; } flags; struct { int uses;