From: Alex Rousskov Date: Sun, 30 Mar 2008 18:20:14 +0000 (-0600) Subject: Migrating from ICAP-specific API to generic "adaptation" API. X-Git-Tag: SQUID_3_1_0_1~49^2~302^2~31 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a83c6ed6d7a6e26b5e15c76226fc498c6d7866ca;p=thirdparty%2Fsquid.git Migrating from ICAP-specific API to generic "adaptation" API. Core Squid code should not care about the specific adaptation mechanism in use. This change should not affect Squid functinality. The migration is not complete because the on/off switch is still ICAP-specific and because comments, debug, and error messages may still refer to ICAP. --- diff --git a/src/ClientRequestContext.h b/src/ClientRequestContext.h index 5dc3a90018..2db77aeb07 100644 --- a/src/ClientRequestContext.h +++ b/src/ClientRequestContext.h @@ -10,8 +10,8 @@ class ClientHttpRequest; /* for CBDATA_CLASS() */ #include "cbdata.h" -#if ICAP_CLIENT -#include "ICAP/ICAPServiceRep.h" +#if USE_ADAPTATION +#include "adaptation/forward.h" #endif class ClientRequestContext : public RefCountable @@ -31,10 +31,10 @@ public: void clientRedirectDone(char *result); void checkNoCache(); void checkNoCacheDone(int answer); -#if ICAP_CLIENT +#if USE_ADAPTATION - void icapAccessCheck(); - void icapAclCheckDone(ICAPServiceRep::Pointer service); + void adaptationAccessCheck(); + void adaptationAclCheckDone(Adaptation::ServicePointer service); #endif ClientHttpRequest *http; @@ -42,9 +42,9 @@ public: int redirect_state; bool http_access_done; -#if ICAP_CLIENT +#if USE_ADAPTATION - bool icap_acl_check_done; + bool adaptation_acl_check_done; #endif bool redirect_done; diff --git a/src/Server.cc b/src/Server.cc index 3e4890e733..489dc2006e 100644 --- a/src/Server.cc +++ b/src/Server.cc @@ -39,17 +39,17 @@ #include "HttpReply.h" #include "errorpage.h" -#if ICAP_CLIENT -#include "ICAP/ICAPModXact.h" +#if USE_ADAPTATION +#include "adaptation/Service.h" #include "ICAP/ICAPConfig.h" extern ICAPConfig TheICAPConfig; #endif ServerStateData::ServerStateData(FwdState *theFwdState): AsyncJob("ServerStateData"),requestSender(NULL) -#if ICAP_CLIENT +#if USE_ADAPTATION , adaptedHeadSource(NULL) - , icapAccessCheckPending(false) - , startedIcap(false) + , adaptationAccessCheckPending(false) + , startedAdaptation(false) #endif { fwd = theFwdState; @@ -73,8 +73,8 @@ ServerStateData::~ServerStateData() if (requestBodySource != NULL) requestBodySource->clearConsumer(); -#if ICAP_CLIENT - cleanIcap(); +#if USE_ADAPTATION + cleanAdaptation(); #endif if (responseBodyBuffer != NULL) { @@ -151,11 +151,11 @@ ServerStateData::serverComplete2() { debugs(11,5,HERE << "serverComplete2 " << this); -#if ICAP_CLIENT +#if USE_ADAPTATION if (virginBodyDestination != NULL) stopProducingFor(virginBodyDestination, true); - if (!doneWithIcap()) + if (!doneWithAdaptation()) return; #endif @@ -167,8 +167,8 @@ ServerStateData::serverComplete2() // to the ICAP service. And vice versa. Here, we quit only if we are done // talking to both. void ServerStateData::quitIfAllDone() { -#if ICAP_CLIENT - if (!doneWithIcap()) { +#if USE_ADAPTATION + if (!doneWithAdaptation()) { debugs(11,5, HERE << "transaction not done: still talking to ICAP"); return; } @@ -226,7 +226,7 @@ ServerStateData::abortOnBadEntry(const char *abortReason) void ServerStateData::noteMoreBodyDataAvailable(BodyPipe::Pointer bp) { -#if ICAP_CLIENT +#if USE_ADAPTATION if (adaptedBodySource == bp) { handleMoreAdaptedBodyAvailable(); return; @@ -239,7 +239,7 @@ ServerStateData::noteMoreBodyDataAvailable(BodyPipe::Pointer bp) void ServerStateData::noteBodyProductionEnded(BodyPipe::Pointer bp) { -#if ICAP_CLIENT +#if USE_ADAPTATION if (adaptedBodySource == bp) { handleAdaptedBodyProductionEnded(); return; @@ -252,7 +252,7 @@ ServerStateData::noteBodyProductionEnded(BodyPipe::Pointer bp) void ServerStateData::noteBodyProducerAborted(BodyPipe::Pointer bp) { -#if ICAP_CLIENT +#if USE_ADAPTATION if (adaptedBodySource == bp) { handleAdaptedBodyProducerAborted(); return; @@ -367,7 +367,7 @@ ServerStateData::sendMoreRequestBody() } } -// called by noteIcapAnswer(), HTTP server overwrites this +// called by noteAdaptationAnswer(), HTTP server overwrites this void ServerStateData::haveParsedReplyHeaders() { @@ -380,22 +380,22 @@ ServerStateData::originalRequest() return request; } -#if ICAP_CLIENT +#if USE_ADAPTATION /* * Initiate an ICAP transaction. Return true on success. * Caller will handle error condition by generating a Squid error message * or take other action. */ bool -ServerStateData::startIcap(ICAPServiceRep::Pointer service, HttpRequest *cause) +ServerStateData::startAdaptation(Adaptation::ServicePointer service, HttpRequest *cause) { - debugs(11, 5, "ServerStateData::startIcap() called"); + debugs(11, 5, "ServerStateData::startAdaptation() called"); if (!service) { - debugs(11, 3, "ServerStateData::startIcap fails: lack of service"); + debugs(11, 3, "ServerStateData::startAdaptation fails: lack of service"); return false; } if (service->broken()) { - debugs(11, 3, "ServerStateData::startIcap fails: broken service"); + debugs(11, 3, "ServerStateData::startAdaptation fails: broken service"); return false; } @@ -414,15 +414,15 @@ ServerStateData::startIcap(ICAPServiceRep::Pointer service, HttpRequest *cause) virginBodyDestination->setBodySize(size); } - adaptedHeadSource = initiateIcap( - new ICAPModXactLauncher(this, vrep, cause, service)); + adaptedHeadSource = initiateAdaptation(service->makeXactLauncher( + this, vrep, cause)); return adaptedHeadSource != NULL; } // properly cleans up ICAP-related state // may be called multiple times -void ServerStateData::cleanIcap() { - debugs(11,5, HERE << "cleaning ICAP; ACL: " << icapAccessCheckPending); +void ServerStateData::cleanAdaptation() { + debugs(11,5, HERE << "cleaning ICAP; ACL: " << adaptationAccessCheckPending); if (virginBodyDestination != NULL) stopProducingFor(virginBodyDestination, false); @@ -432,13 +432,13 @@ void ServerStateData::cleanIcap() { if (adaptedBodySource != NULL) stopConsumingFrom(adaptedBodySource); - if (!icapAccessCheckPending) // we cannot cancel a pending callback - assert(doneWithIcap()); // make sure the two methods are in sync + if (!adaptationAccessCheckPending) // we cannot cancel a pending callback + assert(doneWithAdaptation()); // make sure the two methods are in sync } bool -ServerStateData::doneWithIcap() const { - return !icapAccessCheckPending && +ServerStateData::doneWithAdaptation() const { + return !adaptationAccessCheckPending && !virginBodyDestination && !adaptedHeadSource && !adaptedBodySource; } @@ -446,7 +446,7 @@ ServerStateData::doneWithIcap() const { void ServerStateData::adaptVirginReplyBody(const char *data, ssize_t len) { - assert(startedIcap); + assert(startedAdaptation); if (!virginBodyDestination) { debugs(11,3, HERE << "ICAP does not want more virgin body"); @@ -504,17 +504,17 @@ ServerStateData::noteBodyConsumerAborted(BodyPipe::Pointer) { stopProducingFor(virginBodyDestination, false); - // do not force closeServer here in case we need to bypass IcapQueryAbort + // do not force closeServer here in case we need to bypass AdaptationQueryAbort - if (doneWithIcap()) // we may still be receiving adapted response - handleIcapCompleted(); + if (doneWithAdaptation()) // we may still be receiving adapted response + handleAdaptationCompleted(); } // received adapted response headers (body may follow) void -ServerStateData::noteIcapAnswer(HttpMsg *msg) +ServerStateData::noteAdaptationAnswer(HttpMsg *msg) { - clearIcap(adaptedHeadSource); // we do not expect more messages + clearAdaptation(adaptedHeadSource); // we do not expect more messages if (abortOnBadEntry("entry went bad while waiting for adapted headers")) return; @@ -532,17 +532,17 @@ ServerStateData::noteIcapAnswer(HttpMsg *msg) assert(adaptedBodySource->setConsumerIfNotLate(this)); } else { // no body - if (doneWithIcap()) // we may still be sending virgin response - handleIcapCompleted(); + if (doneWithAdaptation()) // we may still be sending virgin response + handleAdaptationCompleted(); } } // will not receive adapted response headers (and, hence, body) void -ServerStateData::noteIcapQueryAbort(bool final) +ServerStateData::noteAdaptationQueryAbort(bool final) { - clearIcap(adaptedHeadSource); - handleIcapAborted(!final); + clearAdaptation(adaptedHeadSource); + handleAdaptationAborted(!final); } // more adapted response body is available @@ -574,22 +574,22 @@ ServerStateData::handleAdaptedBodyProductionEnded() if (abortOnBadEntry("entry went bad while waiting for adapted body eof")) return; - handleIcapCompleted(); + handleAdaptationCompleted(); } // premature end of the adapted response body void ServerStateData::handleAdaptedBodyProducerAborted() { stopConsumingFrom(adaptedBodySource); - handleIcapAborted(); + handleAdaptationAborted(); } -// common part of noteIcapAnswer and handleAdaptedBodyProductionEnded +// common part of noteAdaptationAnswer and handleAdaptedBodyProductionEnded void -ServerStateData::handleIcapCompleted() +ServerStateData::handleAdaptationCompleted() { - debugs(11,5, HERE << "handleIcapCompleted"); - cleanIcap(); + debugs(11,5, HERE << "handleAdaptationCompleted"); + cleanAdaptation(); // We stop reading origin response because we have no place to put it and // cannot use it. If some origin servers do not like that or if we want to @@ -604,11 +604,11 @@ ServerStateData::handleIcapCompleted() } -// common part of noteIcap*Aborted and noteBodyConsumerAborted methods +// common part of noteAdaptation*Aborted and noteBodyConsumerAborted methods void -ServerStateData::handleIcapAborted(bool bypassable) +ServerStateData::handleAdaptationAborted(bool bypassable) { - debugs(11,5, HERE << "handleIcapAborted; bypassable: " << bypassable << + debugs(11,5, HERE << "handleAdaptationAborted; bypassable: " << bypassable << ", entry empty: " << entry->isEmpty()); if (abortOnBadEntry("entry went bad while ICAP aborted")) @@ -629,9 +629,9 @@ ServerStateData::handleIcapAborted(bool bypassable) } void -ServerStateData::icapAclCheckDone(ICAPServiceRep::Pointer service) +ServerStateData::adaptationAclCheckDone(Adaptation::ServicePointer service) { - icapAccessCheckPending = false; + adaptationAccessCheckPending = false; if (abortOnBadEntry("entry went bad while waiting for ICAP ACL check")) return; @@ -644,9 +644,9 @@ ServerStateData::icapAclCheckDone(ICAPServiceRep::Pointer service) } // TODO: Should we check received5CBodyTooLarge on the server-side as well? - startedIcap = startIcap(service, originalRequest()); + startedAdaptation = startAdaptation(service, originalRequest()); - if (!startedIcap && (!service || service->bypass)) { + if (!startedAdaptation && (!service || service->cfg().bypass)) { // handle ICAP start failure when no service was selected // or where the selected service was optional setFinalReply(virginReply()); @@ -654,7 +654,7 @@ ServerStateData::icapAclCheckDone(ICAPServiceRep::Pointer service) return; } - if (!startedIcap) { + if (!startedAdaptation) { // handle start failure for an essential ICAP service ErrorState *err = errorCon(ERR_ICAP_FAILURE, HTTP_INTERNAL_SERVER_ERROR, originalRequest()); @@ -668,10 +668,10 @@ ServerStateData::icapAclCheckDone(ICAPServiceRep::Pointer service) } void -ServerStateData::icapAclCheckDoneWrapper(ICAPServiceRep::Pointer service, void *data) +ServerStateData::adaptationAclCheckDoneWrapper(Adaptation::ServicePointer service, void *data) { ServerStateData *state = (ServerStateData *)data; - state->icapAclCheckDone(service); + state->adaptationAclCheckDone(service); } #endif @@ -690,15 +690,15 @@ ServerStateData::sendBodyIsTooLargeError() void ServerStateData::adaptOrFinalizeReply() { -#if ICAP_CLIENT +#if USE_ADAPTATION if (TheICAPConfig.onoff) { - ICAPAccessCheck *icap_access_check = - new ICAPAccessCheck(ICAP::methodRespmod, ICAP::pointPreCache, - request, virginReply(), icapAclCheckDoneWrapper, this); + Adaptation::AccessCheck *check = new Adaptation::AccessCheck( + Adaptation::methodRespmod, ICAP::pointPreCache, + request, virginReply(), adaptationAclCheckDoneWrapper, this); - icapAccessCheckPending = true; - icap_access_check->check(); // will eventually delete self + adaptationAccessCheckPending = true; + check->check(); // will eventually delete self return; } @@ -710,9 +710,9 @@ ServerStateData::adaptOrFinalizeReply() void ServerStateData::addVirginReplyBody(const char *data, ssize_t len) { -#if ICAP_CLIENT - assert(!icapAccessCheckPending); // or would need to buffer while waiting - if (startedIcap) { +#if USE_ADAPTATION + assert(!adaptationAccessCheckPending); // or would need to buffer while waiting + if (startedAdaptation) { adaptVirginReplyBody(data, len); return; } @@ -732,7 +732,7 @@ ServerStateData::storeReplyBody(const char *data, ssize_t len) size_t ServerStateData::replyBodySpace(size_t space) { -#if ICAP_CLIENT +#if USE_ADAPTATION if (responseBodyBuffer) { return 0; // Stop reading if already overflowed waiting for ICAP to catch up } @@ -750,13 +750,14 @@ size_t ServerStateData::replyBodySpace(size_t space) * The BodyPipe will call our noteMoreBodySpaceAvailable() method * when it has free space again. */ - size_t icap_space = virginBodyDestination->buf().potentialSpaceSize(); + size_t adaptation_space = + virginBodyDestination->buf().potentialSpaceSize(); - debugs(11,9, "ServerStateData may read up to min(" << icap_space << - ", " << space << ") bytes"); + debugs(11,9, "ServerStateData may read up to min(" << + adaptation_space << ", " << space << ") bytes"); - if (icap_space < space) - space = icap_space; + if (adaptation_space < space) + space = adaptation_space; } #endif diff --git a/src/Server.h b/src/Server.h index 6369d63a8f..807d08e5f8 100644 --- a/src/Server.h +++ b/src/Server.h @@ -52,16 +52,14 @@ #include "ICAP/AsyncJob.h" #include "CommCalls.h" -#if ICAP_CLIENT -#include "ICAP/ICAPServiceRep.h" -#include "ICAP/ICAPInitiator.h" - -class ICAPAccessCheck; +#if USE_ADAPTATION +#include "adaptation/forward.h" +#include "adaptation/Initiator.h" #endif class ServerStateData: -#if ICAP_CLIENT - public ICAPInitiator, +#if USE_ADAPTATION + public Adaptation::Initiator, public BodyProducer, #endif public BodyConsumer @@ -90,13 +88,13 @@ public: // a hack to reach HttpStateData::orignal_request virtual HttpRequest *originalRequest(); -#if ICAP_CLIENT - void icapAclCheckDone(ICAPServiceRep::Pointer); - static void icapAclCheckDoneWrapper(ICAPServiceRep::Pointer service, void *data); +#if USE_ADAPTATION + void adaptationAclCheckDone(Adaptation::ServicePointer service); + static void adaptationAclCheckDoneWrapper(Adaptation::ServicePointer service, void *data); // ICAPInitiator: start an ICAP transaction and receive adapted headers. - virtual void noteIcapAnswer(HttpMsg *message); - virtual void noteIcapQueryAbort(bool final); + virtual void noteAdaptationAnswer(HttpMsg *message); + virtual void noteAdaptationQueryAbort(bool final); // BodyProducer: provide virgin response body to ICAP. virtual void noteMoreBodySpaceAvailable(BodyPipe::Pointer ); @@ -106,8 +104,8 @@ public: //AsyncJob virtual methods virtual bool doneAll() const { return -#if ICAP_CLIENT - ICAPInitiator::doneAll() && +#if USE_ADAPTATION + Adaptation::Initiator::doneAll() && BodyProducer::doneAll() && #endif BodyConsumer::doneAll() && false;} @@ -142,19 +140,19 @@ protected: // Entry-dependent callbacks use this check to quit if the entry went bad bool abortOnBadEntry(const char *abortReason); -#if ICAP_CLIENT - bool startIcap(ICAPServiceRep::Pointer, HttpRequest *cause); +#if USE_ADAPTATION + bool startAdaptation(Adaptation::ServicePointer service, HttpRequest *cause); void adaptVirginReplyBody(const char *buf, ssize_t len); - void cleanIcap(); - virtual bool doneWithIcap() const; // did we end ICAP communication? + void cleanAdaptation(); + virtual bool doneWithAdaptation() const; // did we end ICAP communication? // BodyConsumer for ICAP: consume adapted response body. void handleMoreAdaptedBodyAvailable(); void handleAdaptedBodyProductionEnded(); void handleAdaptedBodyProducerAborted(); - void handleIcapCompleted(); - void handleIcapAborted(bool bypassable = false); + void handleAdaptationCompleted(); + void handleAdaptationAborted(bool bypassable = false); #endif protected: @@ -184,13 +182,13 @@ protected: BodyPipe::Pointer requestBodySource; // to consume request body AsyncCall::Pointer requestSender; // set if we are expecting comm_write to call us back -#if ICAP_CLIENT +#if USE_ADAPTATION BodyPipe::Pointer virginBodyDestination; // to provide virgin response body - ICAPInitiate *adaptedHeadSource; // to get adapted response headers + Adaptation::Initiate *adaptedHeadSource; // to get adapted response headers BodyPipe::Pointer adaptedBodySource; // to consume adated response body - bool icapAccessCheckPending; - bool startedIcap; + bool adaptationAccessCheckPending; + bool startedAdaptation; #endif private: diff --git a/src/client_side_request.cc b/src/client_side_request.cc index 8d4375f61d..768d2f1334 100644 --- a/src/client_side_request.cc +++ b/src/client_side_request.cc @@ -59,12 +59,9 @@ #include "SquidTime.h" #include "wordlist.h" -#if ICAP_CLIENT -#include "ICAP/ICAPModXact.h" -#include "ICAP/ICAPElements.h" -#include "ICAP/ICAPConfig.h" -static void icapAclCheckDoneWrapper(ICAPServiceRep::Pointer service, void *data); -extern ICAPConfig TheICAPConfig; +#if USE_ADAPTATION +#include "ICAP/ICAPConfig.h" /* XXX: replace with generic adaptation config */ +static void adaptationAclCheckDoneWrapper(Adaptation::ServicePointer service, void *data); #endif #if LINGERING_CLOSE @@ -144,7 +141,7 @@ ClientHttpRequest::operator delete (void *address) } ClientHttpRequest::ClientHttpRequest(ConnStateData * aConn) : -#if ICAP_CLIENT +#if USE_ADAPTATION AsyncJob("ClientHttpRequest"), #endif loggingEntry_(NULL) @@ -152,7 +149,7 @@ loggingEntry_(NULL) start_time = current_time; setConn(aConn); dlinkAdd(this, &active, &ClientActiveRequests); -#if ICAP_CLIENT +#if USE_ADAPTATION request_satisfaction_mode = false; #endif } @@ -255,11 +252,11 @@ ClientHttpRequest::~ClientHttpRequest() freeResources(); -#if ICAP_CLIENT - announceInitiatorAbort(icapHeadSource); +#if USE_ADAPTATION + announceInitiatorAbort(virginHeadSource); - if (icapBodySource != NULL) - stopConsumingFrom(icapBodySource); + if (adaptedBodySource != NULL) + stopConsumingFrom(adaptedBodySource); #endif if (calloutContext) @@ -483,43 +480,38 @@ ClientRequestContext::clientAccessCheckDone(int answer) http->doCallouts(); } -#if ICAP_CLIENT +#if USE_ADAPTATION void -ClientRequestContext::icapAccessCheck() +ClientRequestContext::adaptationAccessCheck() { - ICAPAccessCheck *icap_access_check; + Adaptation::AccessCheck *check = new Adaptation::AccessCheck( + Adaptation::methodReqmod, Adaptation::pointPreCache, + http->request, NULL, adaptationAclCheckDoneWrapper, this); - icap_access_check = new ICAPAccessCheck(ICAP::methodReqmod, ICAP::pointPreCache, http->request, NULL, icapAclCheckDoneWrapper, this); - - if (icap_access_check != NULL) { - icap_access_check->check(); - return; - } - - http->doCallouts(); + check->check(); // will eventually delete self } static void -icapAclCheckDoneWrapper(ICAPServiceRep::Pointer service, void *data) +adaptationAclCheckDoneWrapper(Adaptation::ServicePointer service, void *data) { ClientRequestContext *calloutContext = (ClientRequestContext *)data; if (!calloutContext->httpStateIsValid()) return; - calloutContext->icapAclCheckDone(service); + calloutContext->adaptationAclCheckDone(service); } void -ClientRequestContext::icapAclCheckDone(ICAPServiceRep::Pointer service) +ClientRequestContext::adaptationAclCheckDone(Adaptation::ServicePointer service) { - debugs(93,3,HERE << this << " icapAclCheckDone called"); + debugs(93,3,HERE << this << " adaptationAclCheckDone called"); assert(http); - if (http->startIcap(service)) + if (http->startAdaptation(service)) return; - if (!service || service->bypass) { + if (!service || service->cfg().bypass) { // handle ICAP start failure when no service was selected // or where the selected service was optional http->doCallouts(); @@ -527,7 +519,7 @@ ClientRequestContext::icapAclCheckDone(ICAPServiceRep::Pointer service) } // handle start failure for an essential ICAP service - http->handleIcapFailure(); + http->handleAdaptationFailure(); } #endif @@ -1071,11 +1063,11 @@ ClientHttpRequest::doCallouts() return; } -#if ICAP_CLIENT - if (TheICAPConfig.onoff && !calloutContext->icap_acl_check_done) { - debugs(83, 3, HERE << "Doing calloutContext->icapAccessCheck()"); - calloutContext->icap_acl_check_done = true; - calloutContext->icapAccessCheck(); +#if USE_ADAPTATION + if (TheICAPConfig.onoff && !calloutContext->adaptation_acl_check_done) { + debugs(83, 3, HERE << "Doing calloutContext->adaptationAccessCheck()"); + calloutContext->adaptation_acl_check_done = true; + calloutContext->adaptationAccessCheck(); return; } @@ -1138,33 +1130,34 @@ ClientHttpRequest::doCallouts() #include "client_side_request.cci" #endif -#if ICAP_CLIENT +#if USE_ADAPTATION /* * Initiate an ICAP transaction. Return false on errors. * The caller must handle errors. */ bool -ClientHttpRequest::startIcap(ICAPServiceRep::Pointer service) +ClientHttpRequest::startAdaptation(Adaptation::ServicePointer service) { - debugs(85, 3, HERE << this << " ClientHttpRequest::startIcap() called"); + debugs(85, 3, HERE << this << " ClientHttpRequest::startAdaptation() called"); if (!service) { - debugs(85, 3, "ClientHttpRequest::startIcap fails: lack of service"); + debugs(85, 3, "ClientHttpRequest::startAdaptation fails: lack of service"); return false; } if (service->broken()) { - debugs(85, 3, "ClientHttpRequest::startIcap fails: broken service"); + debugs(85, 3, "ClientHttpRequest::startAdaptation fails: broken service"); return false; } - assert(!icapHeadSource); - assert(!icapBodySource); - icapHeadSource = initiateIcap( - new ICAPModXactLauncher(this, request, NULL, service)); - return icapHeadSource != NULL; + assert(!virginHeadSource); + assert(!adaptedBodySource); + virginHeadSource = initiateAdaptation(service->makeXactLauncher( + this, request, NULL)); + + return virginHeadSource != NULL; } void -ClientHttpRequest::noteIcapAnswer(HttpMsg *msg) +ClientHttpRequest::noteAdaptationAnswer(HttpMsg *msg) { assert(cbdataReferenceValid(this)); // indicates bug assert(msg); @@ -1187,8 +1180,8 @@ ClientHttpRequest::noteIcapAnswer(HttpMsg *msg) // subscribe to receive reply body if (new_rep->body_pipe != NULL) { - icapBodySource = new_rep->body_pipe; - assert(icapBodySource->setConsumerIfNotLate(this)); + adaptedBodySource = new_rep->body_pipe; + assert(adaptedBodySource->setConsumerIfNotLate(this)); } clientStreamNode *node = (clientStreamNode *)client_stream.tail->prev->data; @@ -1200,34 +1193,34 @@ ClientHttpRequest::noteIcapAnswer(HttpMsg *msg) request_satisfaction_offset = 0; storeEntry()->replaceHttpReply(new_rep); - if (!icapBodySource) // no body + if (!adaptedBodySource) // no body storeEntry()->complete(); clientGetMoreData(node, this); } // we are done with getting headers (but may be receiving body) - clearIcap(icapHeadSource); + clearAdaptation(virginHeadSource); if (!request_satisfaction_mode) doCallouts(); } void -ClientHttpRequest::noteIcapQueryAbort(bool final) +ClientHttpRequest::noteAdaptationQueryAbort(bool final) { - clearIcap(icapHeadSource); - assert(!icapBodySource); - handleIcapFailure(!final); + clearAdaptation(virginHeadSource); + assert(!adaptedBodySource); + handleAdaptationFailure(!final); } void ClientHttpRequest::noteMoreBodyDataAvailable(BodyPipe::Pointer) { assert(request_satisfaction_mode); - assert(icapBodySource != NULL); + assert(adaptedBodySource != NULL); - if (const size_t contentSize = icapBodySource->buf().contentSize()) { - BodyPipeCheckout bpc(*icapBodySource); + if (const size_t contentSize = adaptedBodySource->buf().contentSize()) { + BodyPipeCheckout bpc(*adaptedBodySource); const StoreIOBuffer ioBuf(&bpc.buf, request_satisfaction_offset); storeEntry()->write(ioBuf); // assume can write everything @@ -1236,7 +1229,7 @@ ClientHttpRequest::noteMoreBodyDataAvailable(BodyPipe::Pointer) bpc.checkIn(); } - if (icapBodySource->exhausted()) + if (adaptedBodySource->exhausted()) endRequestSatisfaction(); // else wait for more body data } @@ -1244,12 +1237,12 @@ ClientHttpRequest::noteMoreBodyDataAvailable(BodyPipe::Pointer) void ClientHttpRequest::noteBodyProductionEnded(BodyPipe::Pointer) { - assert(!icapHeadSource); - if (icapBodySource != NULL) { // did not end request satisfaction yet + assert(!virginHeadSource); + if (adaptedBodySource != NULL) { // did not end request satisfaction yet // We do not expect more because noteMoreBodyDataAvailable always // consumes everything. We do not even have a mechanism to consume // leftovers after noteMoreBodyDataAvailable notifications seize. - assert(icapBodySource->exhausted()); + assert(adaptedBodySource->exhausted()); endRequestSatisfaction(); } } @@ -1258,7 +1251,7 @@ void ClientHttpRequest::endRequestSatisfaction() { debugs(85,4, HERE << this << " ends request satisfaction"); assert(request_satisfaction_mode); - stopConsumingFrom(icapBodySource); + stopConsumingFrom(adaptedBodySource); // TODO: anything else needed to end store entry formation correctly? storeEntry()->complete(); @@ -1267,15 +1260,15 @@ ClientHttpRequest::endRequestSatisfaction() { void ClientHttpRequest::noteBodyProducerAborted(BodyPipe::Pointer) { - assert(!icapHeadSource); - stopConsumingFrom(icapBodySource); - handleIcapFailure(); + assert(!virginHeadSource); + stopConsumingFrom(adaptedBodySource); + handleAdaptationFailure(); } void -ClientHttpRequest::handleIcapFailure(bool bypassable) +ClientHttpRequest::handleAdaptationFailure(bool bypassable) { - debugs(85,3, HERE << "handleIcapFailure(" << bypassable << ")"); + debugs(85,3, HERE << "handleAdaptationFailure(" << bypassable << ")"); const bool usedStore = storeEntry() && !storeEntry()->isEmpty(); const bool usedPipe = request->body_pipe != NULL && diff --git a/src/client_side_request.h b/src/client_side_request.h index e7ed085016..b8caa7a43c 100644 --- a/src/client_side_request.h +++ b/src/client_side_request.h @@ -43,9 +43,9 @@ #include "dlink.h" #include "ICAP/AsyncJob.h" -#if ICAP_CLIENT -#include "ICAP/ICAPServiceRep.h" -#include "ICAP/ICAPInitiator.h" +#if USE_ADAPTATION +#include "adaptation/forward.h" +#include "adaptation/Initiator.h" class HttpMsg; #endif @@ -60,8 +60,8 @@ class ConnStateData; class ClientRequestContext; class ClientHttpRequest -#if ICAP_CLIENT - : public ICAPInitiator, // to start ICAP transactions +#if USE_ADAPTATION + : public Adaptation::Initiator, // to start adaptation transactions public BodyConsumer // to receive reply bodies in request satisf. mode #endif { @@ -69,7 +69,7 @@ class ClientHttpRequest public: void *operator new (size_t); void operator delete (void *); -#if ICAP_CLIENT +#if USE_ADAPTATION void *toCbdata() { return this; } #endif ClientHttpRequest(ConnStateData *); @@ -150,9 +150,9 @@ unsigned int purging: ClientRequestContext *calloutContext; void doCallouts(); -#if ICAP_CLIENT -//AsyncJob virtual methods - virtual bool doneAll() const { return ICAPInitiator::doneAll() && +#if USE_ADAPTATION + // AsyncJob virtual methods + virtual bool doneAll() const { return Initiator::doneAll() && BodyConsumer::doneAll() && false;} #endif @@ -170,18 +170,18 @@ public: void sslBumpEstablish(comm_err_t errflag); #endif -#if ICAP_CLIENT +#if USE_ADAPTATION public: - bool startIcap(ICAPServiceRep::Pointer); + bool startAdaptation(Adaptation::ServicePointer); // private but exposed for ClientRequestContext - void handleIcapFailure(bool bypassable = false); + void handleAdaptationFailure(bool bypassable = false); private: // ICAPInitiator API, called by ICAPXaction - virtual void noteIcapAnswer(HttpMsg *message); - virtual void noteIcapQueryAbort(bool final); + virtual void noteAdaptationAnswer(HttpMsg *message); + virtual void noteAdaptationQueryAbort(bool final); // BodyConsumer API, called by BodyPipe virtual void noteMoreBodyDataAvailable(BodyPipe::Pointer); @@ -191,8 +191,8 @@ private: void endRequestSatisfaction(); private: - ICAPInitiate *icapHeadSource; - BodyPipe::Pointer icapBodySource; + Adaptation::Initiate *virginHeadSource; + BodyPipe::Pointer adaptedBodySource; bool request_satisfaction_mode; int64_t request_satisfaction_offset; diff --git a/src/ftp.cc b/src/ftp.cc index e4f3d2ad8a..56c31d8980 100644 --- a/src/ftp.cc +++ b/src/ftp.cc @@ -1385,10 +1385,10 @@ FtpStateData::processReplyBody() return; } -#if ICAP_CLIENT +#if USE_ADAPTATION - if (icapAccessCheckPending) { - debugs(9,3, HERE << "returning from FtpStateData::processReplyBody due to icapAccessCheckPending"); + if (adaptationAccessCheckPending) { + debugs(9,3, HERE << "returning from FtpStateData::processReplyBody due to adaptationAccessCheckPending"); return; } @@ -2594,9 +2594,9 @@ FtpStateData::processHeadResponse() return; } -#if ICAP_CLIENT - if (icapAccessCheckPending) { - debugs(9,3, HERE << "returning due to icapAccessCheckPending"); +#if USE_ADAPTATION + if (adaptationAccessCheckPending) { + debugs(9,3, HERE << "returning due to adaptationAccessCheckPending"); return; } #endif diff --git a/src/http.cc b/src/http.cc index 3b48de45d7..933cfad97b 100644 --- a/src/http.cc +++ b/src/http.cc @@ -1175,8 +1175,8 @@ HttpStateData::processReplyBody() return; } -#if ICAP_CLIENT - if (icapAccessCheckPending) +#if USE_ADAPTATION + if (adaptationAccessCheckPending) return; #endif