Commit 516659f9 authored by Jakob Otto's avatar Jakob Otto

Implement read retries for udp

parent b5c3fb8a
...@@ -79,20 +79,23 @@ public: ...@@ -79,20 +79,23 @@ public:
} }
bool handle_read_event(endpoint_manager&) override { bool handle_read_event(endpoint_manager&) override {
CAF_LOG_TRACE(CAF_ARG(this->handle_.id)); size_t reads = 0;
auto ret = read(this->handle_, this->read_buf_); while (reads++ < this->max_consecutive_reads_) {
if (auto res = get_if<std::pair<size_t, ip_endpoint>>(&ret)) { CAF_LOG_TRACE(CAF_ARG(this->handle_.id));
auto num_bytes = res->first; auto ret = read(this->handle_, this->read_buf_);
CAF_LOG_DEBUG("received " << num_bytes << " bytes"); if (auto res = get_if<std::pair<size_t, ip_endpoint>>(&ret)) {
auto ep = res->second; auto num_bytes = res->first;
this->read_buf_.resize(num_bytes); CAF_LOG_DEBUG("received " << num_bytes << " bytes");
this->next_layer_.handle_data(*this, this->read_buf_, std::move(ep)); auto ep = res->second;
prepare_next_read(); this->read_buf_.resize(num_bytes);
} else { this->next_layer_.handle_data(*this, this->read_buf_, std::move(ep));
auto err = get<sec>(ret); prepare_next_read();
CAF_LOG_DEBUG("send failed" << CAF_ARG(err)); } else {
this->next_layer_.handle_error(err); auto err = get<sec>(ret);
return false; CAF_LOG_DEBUG("send failed" << CAF_ARG(err));
this->next_layer_.handle_error(err);
return false;
}
} }
return true; return true;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment