--------------------- PatchSet 7483 Date: 2008/03/19 22:01:07 Author: chtsanti Branch: async-calls Tag: (none) Log: converting asserts() that are testing local transaction-specific conditions to Must() calls in primary AsyncJob based classes. Members: src/BodyPipe.cc:1.7.4.11->1.7.4.12 src/client_side.cc:1.139.4.10->1.139.4.11 src/client_side_request.cc:1.79.4.11->1.79.4.12 src/http.cc:1.122.4.10->1.122.4.11 Index: squid3/src/BodyPipe.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/BodyPipe.cc,v retrieving revision 1.7.4.11 retrieving revision 1.7.4.12 diff -u -r1.7.4.11 -r1.7.4.12 --- squid3/src/BodyPipe.cc 24 Jan 2008 21:29:15 -0000 1.7.4.11 +++ squid3/src/BodyPipe.cc 19 Mar 2008 22:01:11 -0000 1.7.4.12 @@ -98,7 +98,7 @@ { debugs(91,7, HERE << this << " will not produce for " << pipe << "; atEof: " << atEof); - assert(pipe != NULL); // be strict: the caller state may depend on this + Must(pipe != NULL); // be strict: the caller state may depend on this pipe->clearProducer(atEof); pipe = NULL; } @@ -111,7 +111,7 @@ void BodyConsumer::stopConsumingFrom(RefCount &pipe) { debugs(91,7, HERE << this << " will not consume from " << pipe); - assert(pipe != NULL); // be strict: the caller state may depend on this + Must(pipe != NULL); // be strict: the caller state may depend on this pipe->clearConsumer(); pipe = NULL; } @@ -140,14 +140,14 @@ void BodyPipe::setBodySize(uint64_t aBodySize) { - assert(!bodySizeKnown()); - assert(aBodySize >= 0); - assert(thePutSize <= aBodySize); + Must(!bodySizeKnown()); + Must(aBodySize >= 0); + Must(thePutSize <= aBodySize); // If this assert fails, we need to add code to check for eof and inform // the consumer about the eof condition via scheduleBodyEndNotification, // because just setting a body size limit may trigger the eof condition. - assert(!theConsumer); + Must(!theConsumer); theBodySize = aBodySize; debugs(91,7, HERE << "set body size" << status()); @@ -155,13 +155,13 @@ uint64_t BodyPipe::bodySize() const { - assert(bodySizeKnown()); + Must(bodySizeKnown()); return static_cast(theBodySize); } bool BodyPipe::expectMoreAfter(uint64_t offset) const { - assert(theGetSize <= offset); + Must(theGetSize <= offset); return offset < thePutSize || // buffer has more now or (!productionEnded() && mayNeedMoreData()); // buffer will have more } @@ -190,7 +190,7 @@ debugs(91,3, HERE << "aborting on premature eof" << status()); } else { // asserta that we can detect the abort if the consumer joins later - assert(!bodySizeKnown() || bodySize() != thePutSize); + Must(!bodySizeKnown() || bodySize() != thePutSize); } scheduleBodyEndNotification(); } @@ -214,8 +214,8 @@ bool BodyPipe::setConsumerIfNotLate(Consumer *aConsumer) { - assert(!theConsumer); - assert(aConsumer); + Must(!theConsumer); + Must(aConsumer); // TODO: convert this into an exception and remove IfNotLate suffix // If there is something consumed already, we are in an auto-consuming mode @@ -292,7 +292,7 @@ MemBuf & BodyPipe::checkOut() { - assert(!isCheckedOut); + Must(!isCheckedOut); isCheckedOut = true; return theBuf; } @@ -300,7 +300,7 @@ void BodyPipe::checkIn(Checkout &checkout) { - assert(isCheckedOut); + Must(isCheckedOut); isCheckedOut = false; const size_t currentSize = theBuf.contentSize(); if (checkout.checkedOutSize > currentSize) @@ -313,14 +313,14 @@ void BodyPipe::undoCheckOut(Checkout &checkout) { - assert(isCheckedOut); + Must(isCheckedOut); const size_t currentSize = theBuf.contentSize(); // We can only undo if size did not change, and even that carries // some risk. If this becomes a problem, the code checking out // raw buffers should always check them in (possibly unchanged) // instead of relying on the automated undo mechanism of Checkout. // The code can always use a temporary buffer to accomplish that. - assert(checkout.checkedOutSize == currentSize); + Must(checkout.checkedOutSize == currentSize); } // TODO: Optimize: inform consumer/producer about more data/space only if @@ -328,7 +328,7 @@ void BodyPipe::postConsume(size_t size) { - assert(!isCheckedOut); + Must(!isCheckedOut); theGetSize += size; debugs(91,7, HERE << "consumed " << size << " bytes" << status()); if (mayNeedMoreData()){ @@ -342,7 +342,7 @@ void BodyPipe::postAppend(size_t size) { - assert(!isCheckedOut); + Must(!isCheckedOut); thePutSize += size; debugs(91,7, HERE << "added " << size << " bytes" << status()); @@ -440,7 +440,7 @@ void BodyPipeCheckout::checkIn() { - assert(!checkedIn); + Must(!checkedIn); pipe.checkIn(*this); checkedIn = true; } Index: squid3/src/client_side.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/client_side.cc,v retrieving revision 1.139.4.10 retrieving revision 1.139.4.11 diff -u -r1.139.4.10 -r1.139.4.11 --- squid3/src/client_side.cc 12 Feb 2008 19:04:41 -0000 1.139.4.10 +++ squid3/src/client_side.cc 19 Mar 2008 22:01:10 -0000 1.139.4.11 @@ -1,6 +1,6 @@ /* - * $Id: client_side.cc,v 1.139.4.10 2008/02/12 19:04:41 rousskov Exp $ + * $Id: client_side.cc,v 1.139.4.11 2008/03/19 22:01:10 chtsanti Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -578,17 +578,17 @@ ClientSocketContext::Pointer context; while ((context = getCurrentContext()).getRaw() != NULL) { - assert(getCurrentContext() != + Must(getCurrentContext() != getCurrentContext()->next); context->connIsFinished(); - assert (context != currentobject); + Must(context != currentobject); } } /* This is a handler normally called by comm_close() */ void ConnStateData::connStateClosed(const CommCloseCbParams &io) { - assert (fd == io.fd); + Must (fd == io.fd); close(); } Index: squid3/src/client_side_request.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/client_side_request.cc,v retrieving revision 1.79.4.11 retrieving revision 1.79.4.12 diff -u -r1.79.4.11 -r1.79.4.12 --- squid3/src/client_side_request.cc 12 Feb 2008 19:04:47 -0000 1.79.4.11 +++ squid3/src/client_side_request.cc 19 Mar 2008 22:01:09 -0000 1.79.4.12 @@ -1,6 +1,6 @@ /* - * $Id: client_side_request.cc,v 1.79.4.11 2008/02/12 19:04:47 rousskov Exp $ + * $Id: client_side_request.cc,v 1.79.4.12 2008/03/19 22:01:09 chtsanti Exp $ * * DEBUG: section 85 Client-side Request Routines * AUTHOR: Robert Collins (Originally Duane Wessels in client_side.c) @@ -164,7 +164,7 @@ bool ClientHttpRequest::onlyIfCached()const { - assert(request); + Must(request); return request->cache_control && EBIT_TEST(request->cache_control->mask, CC_ONLY_IF_CACHED); } @@ -244,7 +244,7 @@ /* the ICP check here was erroneous * - StoreEntry::releaseRequest was always called if entry was valid */ - assert(logType < LOG_TYPE_MAX); + Must(logType < LOG_TYPE_MAX); logRequest(); @@ -921,7 +921,7 @@ debugs(85, 4, "ClientHttpRequest::httpStart: " << log_tags[logType] << " for '" << uri << "'"); /* no one should have touched this */ - assert(out.offset == 0); + Must(out.offset == 0); /* Use the Stream Luke */ clientStreamNode *node = (clientStreamNode *)client_stream.tail->data; clientStreamRead(node, this, node->readBuffer); @@ -997,7 +997,7 @@ /** TODO: should be querying the stream. */ int64_t contentLength = memObject()->getReply()->bodySize(request->method); - assert(contentLength >= 0); + Must(contentLength >= 0); if (out.offset < contentLength) return false; @@ -1062,7 +1062,7 @@ void ClientHttpRequest::doCallouts() { - assert(calloutContext); + Must(calloutContext); if (!calloutContext->http_access_done) { debugs(83, 3, HERE << "Doing calloutContext->clientAccessCheck()"); @@ -1083,7 +1083,7 @@ if (!calloutContext->redirect_done) { calloutContext->redirect_done = true; - assert(calloutContext->redirect_state == REDIRECT_NONE); + Must(calloutContext->redirect_state == REDIRECT_NONE); if (Config.Program.redirect) { debugs(83, 3, HERE << "Doing calloutContext->clientRedirectStart()"); @@ -1156,8 +1156,8 @@ return false; } - assert(!icapHeadSource); - assert(!icapBodySource); + Must(!icapHeadSource); + Must(!icapBodySource); icapHeadSource = initiateIcap( new ICAPModXactLauncher(this, request, NULL, service)); return icapHeadSource != NULL; @@ -1166,8 +1166,8 @@ void ClientHttpRequest::noteIcapAnswer(HttpMsg *msg) { - assert(cbdataReferenceValid(this)); // indicates bug - assert(msg); + Must(cbdataReferenceValid(this)); // indicates bug + Must(msg); if (HttpRequest *new_req = dynamic_cast(msg)) { /* @@ -1181,14 +1181,14 @@ xfree(uri); uri = xstrdup(urlCanonical(request)); setLogUri(this, urlCanonicalClean(request)); - assert(request->method.id()); + Must(request->method.id()); } else if (HttpReply *new_rep = dynamic_cast(msg)) { debugs(85,3,HERE << "REQMOD reply is HTTP reply"); // subscribe to receive reply body if (new_rep->body_pipe != NULL) { icapBodySource = new_rep->body_pipe; - assert(icapBodySource->setConsumerIfNotLate(this)); + Must(icapBodySource->setConsumerIfNotLate(this)); } clientStreamNode *node = (clientStreamNode *)client_stream.tail->prev->data; @@ -1216,15 +1216,15 @@ ClientHttpRequest::noteIcapQueryAbort(bool final) { clearIcap(icapHeadSource); - assert(!icapBodySource); + Must(!icapBodySource); handleIcapFailure(!final); } void ClientHttpRequest::noteMoreBodyDataAvailable(BodyPipe::Pointer) { - assert(request_satisfaction_mode); - assert(icapBodySource != NULL); + Must(request_satisfaction_mode); + Must(icapBodySource != NULL); if (const size_t contentSize = icapBodySource->buf().contentSize()) { BodyPipeCheckout bpc(*icapBodySource); @@ -1244,12 +1244,12 @@ void ClientHttpRequest::noteBodyProductionEnded(BodyPipe::Pointer) { - assert(!icapHeadSource); + Must(!icapHeadSource); if (icapBodySource != 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()); + Must(icapBodySource->exhausted()); endRequestSatisfaction(); } } @@ -1257,7 +1257,7 @@ void ClientHttpRequest::endRequestSatisfaction() { debugs(85,4, HERE << this << " ends request satisfaction"); - assert(request_satisfaction_mode); + Must(request_satisfaction_mode); stopConsumingFrom(icapBodySource); // TODO: anything else needed to end store entry formation correctly? @@ -1267,7 +1267,7 @@ void ClientHttpRequest::noteBodyProducerAborted(BodyPipe::Pointer) { - assert(!icapHeadSource); + Must(!icapHeadSource); stopConsumingFrom(icapBodySource); handleIcapFailure(); } @@ -1292,7 +1292,7 @@ clientStreamNode *node = (clientStreamNode *)client_stream.tail->prev->data; clientReplyContext *repContext = dynamic_cast(node->data.getRaw()); - assert(repContext); + Must(repContext); // The original author of the code also wanted to pass an errno to // setReplyToError, but it seems unlikely that the errno reflects the Index: squid3/src/http.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/http.cc,v retrieving revision 1.122.4.10 retrieving revision 1.122.4.11 diff -u -r1.122.4.10 -r1.122.4.11 --- squid3/src/http.cc 12 Feb 2008 19:04:58 -0000 1.122.4.10 +++ squid3/src/http.cc 19 Mar 2008 22:01:07 -0000 1.122.4.11 @@ -1,6 +1,6 @@ /* - * $Id: http.cc,v 1.122.4.10 2008/02/12 19:04:58 rousskov Exp $ + * $Id: http.cc,v 1.122.4.11 2008/03/19 22:01:07 chtsanti Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -265,7 +265,7 @@ if (!remove && !forbidden) return; - assert(e->mem_obj); + Must(e->mem_obj); if (e->mem_obj->request) pe = storeGetPublicByRequest(e->mem_obj->request); @@ -273,7 +273,7 @@ pe = storeGetPublic(e->mem_obj->url, e->mem_obj->method); if (pe != NULL) { - assert(e != pe); + Must(e != pe); pe->release(); } @@ -287,7 +287,7 @@ pe = storeGetPublic(e->mem_obj->url, METHOD_HEAD); if (pe != NULL) { - assert(e != pe); + Must(e != pe); pe->release(); } @@ -322,7 +322,7 @@ pe = storeGetPublic(e->mem_obj->url, METHOD_GET); if (pe != NULL) { - assert(e != pe); + Must(e != pe); pe->release(); } @@ -704,7 +704,7 @@ Ctx ctx = ctx_enter(entry->mem_obj->url); debugs(11, 3, "processReplyHeader: key '" << entry->getMD5Text() << "'"); - assert(!flags.headers_parsed); + Must(!flags.headers_parsed); http_status error = HTTP_STATUS_NONE; @@ -735,8 +735,8 @@ } if (!parsed) { // need more data - assert(!error); - assert(!eof); + Must(!error); + Must(!eof); delete newrep; ctx_exit(ctx); return; @@ -972,7 +972,7 @@ int clen; int len = io.size; - assert(fd == io.fd); + Must(fd == io.fd); flags.do_next_read = 0; @@ -1107,12 +1107,12 @@ error = ERR_INVALID_RESP; } } else { - assert(eof); + Must(eof); error = readBuf->hasContent() ? ERR_INVALID_RESP : ERR_ZERO_SIZE_OBJECT; } - assert(error != ERR_NONE); + Must(error != ERR_NONE); entry->reset(); fwd->fail(errorCon(error, HTTP_BAD_GATEWAY, fwd->request)); flags.do_next_read = 0; @@ -1139,8 +1139,8 @@ const char *data = NULL; int len; bool status = false; - assert(flags.chunked); - assert(httpChunkDecoder); + Must(flags.chunked); + Must(httpChunkDecoder); SQUID_ENTER_THROWING_CODE(); MemBuf decodedData; decodedData.init(); @@ -1378,7 +1378,7 @@ const HttpHeaderEntry *e; String strFwd; HttpHeaderPos pos = HttpHeaderInitPos; - assert (hdr_out->owner == hoRequest); + Must (hdr_out->owner == hoRequest); /* append our IMS header */ if (request->lastmod > -1) @@ -1546,7 +1546,7 @@ httpHdrCcSetMaxAge(cc, getMaxAge(url)); if (request->urlpath.size()) - assert(strstr(url, request->urlpath.buf())); + Must(strstr(url, request->urlpath.buf())); } /* Set no-cache if determined needed but not found */ @@ -1788,7 +1788,7 @@ Dialer dialer(this, &HttpStateData::sentRequestBody); requestSender = asyncCall(11,5, "HttpStateData::sentRequestBody", dialer); } else { - assert(!requestBodySource); + Must(!requestBodySource); typedef CommCbMemFunT Dialer; Dialer dialer(this, &HttpStateData::sendComplete); requestSender = asyncCall(11,5, "HttpStateData::SendComplete", dialer); @@ -1903,7 +1903,7 @@ return; } - assert(requestBodySource != NULL); + Must(requestBodySource != NULL); if (requestBodySource->buf().hasContent()) { // XXX: why does not this trigger a debug message on every request?