AsyncJob("Adaptation::Icap::ModXact"),
Adaptation::Icap::Xaction("Adaptation::Icap::ModXact", aService),
virginConsumed(0),
- bodyParser(NULL),
+ bodyParser(nullptr),
canStartBypass(false), // too early
protectGroupBypass(true),
replyHttpHeaderSize(-1),
// reserve an adaptation history slot (attempts are known at this time)
Adaptation::History::Pointer ah = virginRequest().adaptLogHistory();
- if (ah != NULL)
+ if (ah != nullptr)
adaptHistoryId = ah->recordXactStart(service().cfg().key, icap_tr_start, attempts > 1);
estimateVirginBody(); // before virgin disappears!
{
debugs(93, 5, "checking whether to write more" << status());
- if (writer != NULL) // already writing something
+ if (writer != nullptr) // already writing something
return;
switch (state.writing) {
debugs(93, 8, "will write Preview body from " <<
virgin.body_pipe << status());
Must(state.writing == State::writingPreview);
- Must(virgin.body_pipe != NULL);
+ Must(virgin.body_pipe != nullptr);
const size_t sizeMax = (size_t)virgin.body_pipe->buf().contentSize();
const size_t size = min(preview.debt(), sizeMax);
void Adaptation::Icap::ModXact::writeSomeBody(const char *label, size_t size)
{
Must(!writer && state.writing < state.writingAlmostDone);
- Must(virgin.body_pipe != NULL);
+ Must(virgin.body_pipe != nullptr);
debugs(93, 8, "will write up to " << size << " bytes of " <<
label);
if (state.writing == State::writingReallyDone)
return;
- if (writer != NULL) {
+ if (writer != nullptr) {
if (nicely) {
debugs(93, 7, "will wait for the last write" << status());
state.writing = State::writingAlmostDone; // may already be set
void Adaptation::Icap::ModXact::readMore()
{
- if (reader != NULL || doneReading()) {
+ if (reader != nullptr || doneReading()) {
debugs(93,3, "returning from readMore because reader or doneReading()");
return;
}
// do not fill readBuf if we have no space to store the result
- if (adapted.body_pipe != NULL &&
+ if (adapted.body_pipe != nullptr &&
!adapted.body_pipe->buf().hasPotentialSpace()) {
debugs(93,3, "not reading because ICAP reply pipe is full");
return;
void Adaptation::Icap::ModXact::echoMore()
{
Must(state.sending == State::sendingVirgin);
- Must(adapted.body_pipe != NULL);
+ Must(adapted.body_pipe != nullptr);
Must(virginBodySending.active());
const size_t sizeMax = virginContentSize(virginBodySending);
if (state.sending != State::sendingUndecided) {
debugs(93, 7, "will no longer send" << status());
- if (adapted.body_pipe != NULL) {
+ if (adapted.body_pipe != nullptr) {
virginBodySending.disable();
// we may leave debts if we were echoing and the virgin
// body_pipe got exhausted before we echoed all planned bytes
// update the cross-transactional database if needed (all status codes!)
if (const char *xxName = Adaptation::Config::masterx_shared_name) {
Adaptation::History::Pointer ah = request->adaptHistory(true);
- if (ah != NULL) { // TODO: reorder checks to avoid creating history
+ if (ah != nullptr) { // TODO: reorder checks to avoid creating history
const String val = icapReply->header.getByName(xxName);
if (val.size() > 0) // XXX: HttpHeader lacks empty value detection
ah->updateXxRecord(xxName, val);
String services;
if (icapReply->header.getList(Http::HdrType::X_NEXT_SERVICES, &services)) {
Adaptation::History::Pointer ah = request->adaptHistory(true);
- if (ah != NULL)
+ if (ah != nullptr)
ah->updateNextServices(services);
}
} // TODO: else warn (occasionally!) if we got Http::HdrType::X_NEXT_SERVICES
// request, old headers will be replaced with the new one.
Adaptation::History::Pointer ah = request->adaptLogHistory();
- if (ah != NULL)
+ if (ah != nullptr)
ah->recordMeta(&icapReply->header);
// handle100Continue() manages state.writing on its own.
adapted.header);
// setup adapted body pipe if needed
- if (oldHead->body_pipe != NULL) {
+ if (oldHead->body_pipe != nullptr) {
debugs(93, 7, "will echo virgin body from " <<
oldHead->body_pipe);
if (!virginBodySending.active())
void Adaptation::Icap::ModXact::prepPartialBodyEchoing(uint64_t pos)
{
Must(virginBodySending.active());
- Must(virgin.header->body_pipe != NULL);
+ Must(virgin.header->body_pipe != nullptr);
setOutcome(xoPartEcho);
// update adaptation history if start was called and we reserved a slot
Adaptation::History::Pointer ah = virginRequest().adaptLogHistory();
- if (ah != NULL && adaptHistoryId >= 0)
+ if (ah != nullptr && adaptHistoryId >= 0)
ah->recordXactFinish(adaptHistoryId);
Adaptation::Icap::Xaction::swanSong();
}
Adaptation::Icap::History::Pointer h = virgin_request_->icapHistory();
- Must(h != NULL); // ICAPXaction::maybeLog calls only if there is a log
+ Must(h != nullptr); // ICAPXaction::maybeLog calls only if there is a log
al.icp.opcode = ICP_INVALID;
al.url = h->log_uri.termedBuf();
const Adaptation::Icap::ServiceRep &s = service();
virgin_msg = virgin_request_;
assert(virgin_msg != virgin.cause);
al.http.clientRequestSz.header = virgin_msg->hdr_sz;
- if (virgin_msg->body_pipe != NULL)
+ if (virgin_msg->body_pipe != nullptr)
al.http.clientRequestSz.payloadData = virgin_msg->body_pipe->producedSize();
// leave al.icap.bodyBytesRead negative if no body
// share the cross-transactional database records if needed
if (Adaptation::Config::masterx_shared_name) {
Adaptation::History::Pointer ah = request->adaptHistory(false);
- if (ah != NULL) {
+ if (ah != nullptr) {
String name, value;
if (ah->getXxRecord(name, value)) {
buf.appendf(SQUIDSTRINGPH ": " SQUIDSTRINGPH "\r\n", SQUIDSTRINGPRINT(name), SQUIDSTRINGPRINT(value));
buf.append(matched.rawContent(), matched.length());
buf.append("\r\n", 2);
Adaptation::History::Pointer ah = request->adaptHistory(false);
- if (ah != NULL) {
- if (ah->metaHeaders == NULL)
+ if (ah != nullptr) {
+ if (ah->metaHeaders == nullptr)
ah->metaHeaders = new NotePairs;
if (!ah->metaHeaders->hasPair(h->key(), matched))
ah->metaHeaders->add(h->key(), matched);
struct base64_encode_ctx ctx;
base64_encode_init(&ctx);
- const char *value = NULL;
- if (request->auth_user_request != NULL) {
+ const char *value = nullptr;
+ if (request->auth_user_request != nullptr) {
value = request->auth_user_request->username();
} else if (request->extacl_user.size() > 0) {
value = request->extacl_user.termedBuf();
if (state.serviceWaiting)
buf.append("U", 1);
- if (virgin.body_pipe != NULL)
+ if (virgin.body_pipe != nullptr)
buf.append("R", 1);
if (haveConnection() && !doneReading())
virginBodyWriting.plan();
// sign up as a body consumer
- Must(msg->body_pipe != NULL);
+ Must(msg->body_pipe != nullptr);
Must(msg->body_pipe == virgin.body_pipe);
Must(virgin.body_pipe->setConsumerIfNotLate(this));
Must(TheBackupLimit <= static_cast<size_t>(msg->body_pipe->buf().max_capacity));
} else {
debugs(93, 6, "does not expect virgin body");
- Must(msg->body_pipe == NULL);
+ Must(msg->body_pipe == nullptr);
checkConsuming();
}
}
bool Adaptation::Icap::ModXact::fillVirginHttpHeader(MemBuf &mb) const
{
- if (virgin.header == NULL)
+ if (virgin.header == nullptr)
return false;
virgin.header->firstLineBuf(mb);
{
Adaptation::Icap::ServiceRep::Pointer s =
dynamic_cast<Adaptation::Icap::ServiceRep*>(theService.getRaw());
- Must(s != NULL);
+ Must(s != nullptr);
return new Adaptation::Icap::ModXact(virgin.header, virgin.cause, al, s);
}
// r should never be NULL but we play safe; TODO: add Should()
if (r) {
Adaptation::Icap::History::Pointer h = r->icapHistory();
- if (h != NULL) {
+ if (h != nullptr) {
if (doStart)
h->start("ICAPModXactLauncher");
else