Skip to content

Commit

Permalink
proxy client: fix leak in sendListen
Browse files Browse the repository at this point in the history
  • Loading branch information
aberaud committed Nov 19, 2024
1 parent 078e0a0 commit 134b378
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/dht_proxy_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1121,10 +1121,12 @@ DhtProxyClient::sendListen(const restinio::http_request_header_t& header,
std::lock_guard<std::mutex> l(requestLock_);
requests_[reqid] = request;
}
request->add_on_status_callback([request, seconds = this->listenKeepIdle()] (unsigned status_code) {
request->add_on_status_callback([r=std::weak_ptr(request), seconds = this->listenKeepIdle()] (unsigned status_code) {
if(status_code == 200) {
// increase TCP_KEEPIDLE to save power
request->get_connection()->set_keepalive(seconds);
if (auto request = r.lock()) {
request->get_connection()->set_keepalive(seconds);
}
}
});
request->send();
Expand Down

0 comments on commit 134b378

Please sign in to comment.