Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proxy client: retry permanent put after reconnect #680

Merged
merged 1 commit into from
Nov 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/dht_proxy_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ void
DhtProxyClient::doPut(const InfoHash& key, Sp<Value> val, DoneCallbackSimple cb, time_point /*created*/, bool permanent)
{
if (logger_)
logger_->d("[proxy:client] [put] [search %s] executing for %s", key.to_c_str(), val->toString().c_str());
logger_->debug("[proxy:client] [put] [search {}] executing for {}", key, val->toString());

try {
auto request = buildRequest("/key/" + key.toString());
Expand Down Expand Up @@ -539,12 +539,12 @@ DhtProxyClient::doPut(const InfoHash& key, Sp<Value> val, DoneCallbackSimple cb,
}
} else {
if (logger_)
logger_->e("[proxy:client] [status] failed to parse value from server", response.status_code);
logger_->error("[proxy:client] [put] failed to parse value from server: {}", err);
}
}
} else {
if (logger_)
logger_->e("[proxy:client] [status] failed with code=%i", response.status_code);
logger_->error("[proxy:client] [put] failed with code={:d}", response.status_code);
if (not response.aborted and response.status_code == 0)
opFailed();
}
Expand All @@ -563,7 +563,8 @@ DhtProxyClient::doPut(const InfoHash& key, Sp<Value> val, DoneCallbackSimple cb,
}
catch (const std::exception &e){
if (logger_)
logger_->e("[proxy:client] [put %s] error: %s", key.to_c_str(), e.what());
logger_->error("[proxy:client] [put {}] error: {}", key, e.what());
opFailed();
}
}

Expand Down Expand Up @@ -1154,7 +1155,7 @@ DhtProxyClient::restartListeners(const asio::error_code &ec)

std::lock_guard<std::mutex> lock(searchLock_);
for (auto& search : searches_) {
auto key = search.first;
const auto& key = search.first;
for (auto& put : search.second.puts) {
doPut(key, put.second.value, [ok = put.second.ok](bool result){
*ok = result;
Expand All @@ -1166,6 +1167,10 @@ DhtProxyClient::restartListeners(const asio::error_code &ec)
put.second.refreshPutTimer->async_wait(std::bind(&DhtProxyClient::handleRefreshPut, this,
std::placeholders::_1, key, put.first));
}
// Restart failed pending puts
for (auto& pput : search.second.pendingPuts) {
doPut(key, pput, {}, time_point::max(), true);
}
}
if (not deviceKey_.empty()) {
if (logger_)
Expand Down
Loading