diff --git a/.github/tour.sh b/.github/tour.sh index b69e6808..3d145b5c 100755 --- a/.github/tour.sh +++ b/.github/tour.sh @@ -8,6 +8,7 @@ do echo "Using compat/${e}" break fi + echo "No compat branch for ${e}. Remaining mainly on the main." done grep -n . ipfs_client_clitester/conanfile.txt diff --git a/library/include/ipfs_client/gw/gateway_request.h b/library/include/ipfs_client/gw/gateway_request.h index 2e85294e..d626ebb6 100644 --- a/library/include/ipfs_client/gw/gateway_request.h +++ b/library/include/ipfs_client/gw/gateway_request.h @@ -30,7 +30,7 @@ std::string_view name(GatewayRequestType); constexpr std::size_t BLOCK_RESPONSE_BUFFER_SIZE = 2 * 1024 * 1024; -class GatewayRequest { +class GatewayRequest : public std::enable_shared_from_this { public: // TODO add BlockSource param using BytesReceivedHook = diff --git a/library/src/ipfs_client/gw/gateway_request.cc b/library/src/ipfs_client/gw/gateway_request.cc index b2de5bef..86c1aa97 100644 --- a/library/src/ipfs_client/gw/gateway_request.cc +++ b/library/src/ipfs_client/gw/gateway_request.cc @@ -382,7 +382,18 @@ bool Self::Finished() const { if (type == GatewayRequestType::Providers) { return false; } - return !dependent || dependent->done(); + if (!dependent) { + LOG(WARNING) << "Gateway request considered finished, because it has no " + "dependent request. Unusual case."; + return true; + } + if (dependent->done()) { + LOG(INFO) << "Gateway request finished because the dependent request is " + "already handled (I am redundant)."; + return true; + } + VLOG(2) << "Gateway request continues: " << debug_string(); + return false; } void Self::FleshOut(ipld::BlockSource& s) const { if (cid.has_value() && cid->valid()) { diff --git a/library/src/ipfs_client/gw/requestor.cc b/library/src/ipfs_client/gw/requestor.cc index 1f83321d..075e2f31 100644 --- a/library/src/ipfs_client/gw/requestor.cc +++ b/library/src/ipfs_client/gw/requestor.cc @@ -26,9 +26,14 @@ Self& Self::or_else(std::shared_ptr p) { } void Self::request(ReqPtr req) { - if (!req || req->Finished()) { + if (!req) { return; } + if (req->Finished()) { + VLOG(2) << "Dropping a finished/zombie request."; + return; + } + VLOG(1) << name() << " handling " << req->debug_string(); switch (handle(req)) { case HandleOutcome::MAYBE_LATER: // TODO diff --git a/library/src/ipfs_client/ipfs_request.cc b/library/src/ipfs_client/ipfs_request.cc index ce99ca7e..145b8e6e 100644 --- a/library/src/ipfs_client/ipfs_request.cc +++ b/library/src/ipfs_client/ipfs_request.cc @@ -8,8 +8,6 @@ using Self = ipfs::IpfsRequest; -// Self::IpfsRequest(std::string path_p) -// : path_{path_p}, callback_([](auto&, auto&) {}) {} Self::IpfsRequest(std::string path_p, Finisher f) : path_{path_p}, callback_{f} {} @@ -22,6 +20,7 @@ std::shared_ptr Self::fromUrl(std::string url, ipfs::IpfsRequest::Finisher void Self::finish(ipfs::Response& r) { if (callback_) { callback_(*this, r); + LOG(INFO) << "Request finished."; // TODO - cancel other gw req pointing into this callback_ = {}; }