Skip to content

Commit

Permalink
wfm
Browse files Browse the repository at this point in the history
  • Loading branch information
John-LittleBearLabs committed Jul 1, 2024
1 parent d3ef352 commit dae4208
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
1 change: 1 addition & 0 deletions .github/tour.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion library/include/ipfs_client/gw/gateway_request.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<GatewayRequest> {
public:
// TODO add BlockSource param
using BytesReceivedHook =
Expand Down
13 changes: 12 additions & 1 deletion library/src/ipfs_client/gw/gateway_request.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
7 changes: 6 additions & 1 deletion library/src/ipfs_client/gw/requestor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,14 @@ Self& Self::or_else(std::shared_ptr<Self> 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
Expand Down
3 changes: 1 addition & 2 deletions library/src/ipfs_client/ipfs_request.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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} {}

Expand All @@ -22,6 +20,7 @@ std::shared_ptr<Self> 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_ = {};
}
Expand Down

0 comments on commit dae4208

Please sign in to comment.