From c1d4b807ef85918391dfc17cd763e6bf5aff9593 Mon Sep 17 00:00:00 2001 From: Alex Rousskov Date: Tue, 29 Oct 2024 17:00:03 -0400 Subject: [PATCH] index on (no branch): 819f1206 ext_time_quota_acl: remove -l option (#1909) --- .github/workflows/default.yaml | 65 +++----------------------------- src/MemStore.cc | 6 +-- src/Store.h | 3 ++ src/client_side_reply.cc | 2 +- src/store.cc | 13 +++++++ src/store_client.cc | 2 +- test-suite/test-functionality.sh | 10 +++-- 7 files changed, 32 insertions(+), 69 deletions(-) diff --git a/.github/workflows/default.yaml b/.github/workflows/default.yaml index a748d086e11..c88251bb48f 100644 --- a/.github/workflows/default.yaml +++ b/.github/workflows/default.yaml @@ -33,18 +33,18 @@ jobs: sudo apt-get --quiet=2 install libtool-bin - name: Setup a nodejs environment - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: - node-version: 16 + node-version: 20 - name: Checkout Squid sources - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: ${{ env.CHECKOUT_FETCH_DEPTH }} - run: ./bootstrap.sh - run: ./configure --with-openssl - - run: make -j2 + - run: make -j`nproc` - run: | sudo make install sudo chown -R nobody:nogroup /usr/local/squid @@ -58,65 +58,10 @@ jobs: - name: Publish test logs if: success() || failure() - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: test-logs path: | ${{ runner.temp }}/*.log /usr/local/squid/var/logs/overlord/*.log - source-maintenance-tests: - - runs-on: ubuntu-22.04 - - steps: - - name: Install prerequisite packages - run: | - sudo apt-get --quiet=2 update - sudo apt-get --quiet=2 install astyle - sudo apt-get --quiet=2 install gperf - pip install \ - --user \ - --no-cache-dir \ - --disable-pip-version-check \ - --quiet \ - --progress-bar off \ - codespell==1.16 # TODO: Upgrade to codespell v2 - - - uses: actions/checkout@v3 - with: - fetch-depth: ${{ env.CHECKOUT_FETCH_DEPTH }} - - - run: ./test-suite/test-sources.sh - - build-tests: - - strategy: - fail-fast: true - matrix: - os: [ ubuntu-22.04 ] - - runs-on: ${{ matrix.os }} - - steps: - - - name: Install prerequisite Linux packages - if: runner.os == 'Linux' - run: | - # required for "apt-get build-dep" to work - sudo sed --in-place -E 's/# (deb-src.*updates main)/ \1/g' /etc/apt/sources.list - sudo apt-get --quiet=2 update - sudo apt-get --quiet=2 build-dep squid - sudo apt-get --quiet=2 install linuxdoc-tools - - - name: Checkout sources - uses: actions/checkout@v3 - - - run: ./test-builds.sh - - - name: Publish build logs - if: success() || failure() - uses: actions/upload-artifact@v3 - with: - name: build-logs-${{ runner.os }} - path: btlayer-*.log diff --git a/src/MemStore.cc b/src/MemStore.cc index 90bef58325a..b2445527513 100644 --- a/src/MemStore.cc +++ b/src/MemStore.cc @@ -507,9 +507,9 @@ MemStore::copyFromShm(StoreEntry &e, const sfileno index, const Ipc::StoreMapAnc " from " << extra.page << '+' << prefixSize); // parse headers if needed; they might span multiple slices! - auto &reply = e.mem().adjustableBaseReply(); - if (reply.pstate != Http::Message::psParsed) { + if (!e.hasParsedReplyHeader()) { httpHeaderParsingBuffer.append(sliceBuf.data, sliceBuf.length); + auto &reply = e.mem().adjustableBaseReply(); if (reply.parseTerminatedPrefix(httpHeaderParsingBuffer.c_str(), httpHeaderParsingBuffer.length())) httpHeaderParsingBuffer = SBuf(); // we do not need these bytes anymore } @@ -544,7 +544,7 @@ MemStore::copyFromShm(StoreEntry &e, const sfileno index, const Ipc::StoreMapAnc debugs(20, 5, "mem-loaded all " << e.mem_obj->endOffset() << '/' << anchor.basics.swap_file_sz << " bytes of " << e); - if (e.mem().adjustableBaseReply().pstate != Http::Message::psParsed) + if (!e.hasParsedReplyHeader()) throw TextException(ToSBuf("truncated mem-cached headers; accumulated: ", httpHeaderParsingBuffer.length()), Here()); // from StoreEntry::complete() diff --git a/src/Store.h b/src/Store.h index 32937fc36bb..0661700a643 100644 --- a/src/Store.h +++ b/src/Store.h @@ -56,6 +56,9 @@ class StoreEntry : public hash_link, public Packable /// \see MemObject::freshestReply() const HttpReply *hasFreshestReply() const { return mem_obj ? &mem_obj->freshestReply() : nullptr; } + /// whether this entry has access to [deserialized] [HTTP] response headers + bool hasParsedReplyHeader() const; + void write(StoreIOBuffer); /** Check if the Store entry is empty diff --git a/src/client_side_reply.cc b/src/client_side_reply.cc index 601e8bdd70a..5fe6275814d 100644 --- a/src/client_side_reply.cc +++ b/src/client_side_reply.cc @@ -1062,7 +1062,7 @@ clientReplyContext::storeNotOKTransferDone() const assert(mem != nullptr); assert(http->request != nullptr); - if (mem->baseReply().pstate != Http::Message::psParsed) + if (!http->storeEntry()->hasParsedReplyHeader()) /* haven't found end of headers yet */ return 0; diff --git a/src/store.cc b/src/store.cc index cef5a6291b9..e5d5ba29b7b 100644 --- a/src/store.cc +++ b/src/store.cc @@ -227,6 +227,19 @@ StoreEntry::bytesWanted (Range const aRange, bool ignoreDelayPools) cons return mem_obj->mostBytesWanted(aRange.end, ignoreDelayPools); } +bool +StoreEntry::hasParsedReplyHeader() const +{ + if (mem_obj) { + const auto &reply = mem_obj->baseReply(); + if (reply.pstate == Http::Message::psParsed) { + debugs(20, 7, reply.hdr_sz); + return true; + } + } + return false; +} + bool StoreEntry::checkDeferRead(int) const { diff --git a/src/store_client.cc b/src/store_client.cc index 79acd51fec2..01ce0809655 100644 --- a/src/store_client.cc +++ b/src/store_client.cc @@ -633,7 +633,7 @@ store_client::handleBodyFromDisk() if (!answeredOnce()) { // All on-disk responses have HTTP headers. First disk body read(s) // include HTTP headers that we must parse (if needed) and skip. - const auto haveHttpHeaders = entry->mem_obj->baseReply().pstate == Http::Message::psParsed; + const auto haveHttpHeaders = entry->hasParsedReplyHeader(); if (!haveHttpHeaders && !parseHttpHeadersFromDisk()) return; skipHttpHeadersFromDisk(); diff --git a/test-suite/test-functionality.sh b/test-suite/test-functionality.sh index 09518e51e89..70d4325f521 100755 --- a/test-suite/test-functionality.sh +++ b/test-suite/test-functionality.sh @@ -57,11 +57,12 @@ has_commit_by_message() { clone_repo() { local repo_url="$1" local destination_dir="$2" + local branch="$3" if test -e $destination_dir then echo "Skipping already fetched $destination_dir" - elif run git clone --no-tags --quiet --depth=1 --branch production -- "$repo_url" "$destination_dir" + elif run git clone --no-tags --quiet --depth=1 --branch "$branch" -- "$repo_url" "$destination_dir" then if test -e "$destination_dir/package.json" then @@ -93,9 +94,9 @@ start_overlord() { setup_test_tools() { echo "::group::Setup test tools" - clone_repo https://github.com/measurement-factory/daft $DAFT_DIR || return - clone_repo https://github.com/measurement-factory/squid-dafts $SQUID_DAFTS_DIR || return - clone_repo https://github.com/measurement-factory/squid-overlord $SQUID_OVERLORD_DIR || return + clone_repo https://github.com/measurement-factory/daft $DAFT_DIR auto || return + clone_repo https://github.com/measurement-factory/squid-dafts $SQUID_DAFTS_DIR auto || return + clone_repo https://github.com/measurement-factory/squid-overlord $SQUID_OVERLORD_DIR auto || return if ! test -e $SQUID_DAFTS_DIR/src then @@ -221,6 +222,7 @@ main() { proxy-collapsed-forwarding busy-restart truncated-responses + hit-revalidation " tests="$default_tests" fi