Commit cf73bfcb authored by Jakob Otto's avatar Jakob Otto

Switch to error in write_some

parent b0011b48
...@@ -108,8 +108,8 @@ public: ...@@ -108,8 +108,8 @@ public:
return false; return false;
}; };
do { do {
if (!write_some()) if (auto err = write_some())
return false; return err == sec::unavailable_or_would_block;
} while (fetch_next_message()); } while (fetch_next_message());
return !packet_queue_.empty(); return !packet_queue_.empty();
} }
...@@ -161,7 +161,7 @@ private: ...@@ -161,7 +161,7 @@ private:
this->read_buf_.resize(max_datagram_size); this->read_buf_.resize(max_datagram_size);
} }
bool write_some() { error write_some() {
// Helper function to sort empty buffers back into the right caches. // Helper function to sort empty buffers back into the right caches.
auto recycle = [&]() { auto recycle = [&]() {
auto& front = packet_queue_.front(); auto& front = packet_queue_.front();
...@@ -195,10 +195,10 @@ private: ...@@ -195,10 +195,10 @@ private:
CAF_LOG_ERROR("write failed" << CAF_ARG(err)); CAF_LOG_ERROR("write failed" << CAF_ARG(err));
this->next_layer_.handle_error(err); this->next_layer_.handle_error(err);
} }
return false; return err;
} }
} }
return true; return none;
} }
std::deque<packet> packet_queue_; std::deque<packet> packet_queue_;
......
...@@ -115,8 +115,8 @@ public: ...@@ -115,8 +115,8 @@ public:
return false; return false;
}; };
do { do {
if (!write_some()) if (auto err = write_some())
return false; return err == sec::unavailable_or_would_block;
} while (fetch_next_message()); } while (fetch_next_message());
return !write_queue_.empty(); return !write_queue_.empty();
} }
...@@ -167,7 +167,7 @@ private: ...@@ -167,7 +167,7 @@ private:
} }
} }
bool write_some() { error write_some() {
// Helper function to sort empty buffers back into the right caches. // Helper function to sort empty buffers back into the right caches.
auto recycle = [&]() { auto recycle = [&]() {
auto& front = this->write_queue_.front(); auto& front = this->write_queue_.front();
...@@ -203,10 +203,10 @@ private: ...@@ -203,10 +203,10 @@ private:
CAF_LOG_DEBUG("send failed" << CAF_ARG(err)); CAF_LOG_DEBUG("send failed" << CAF_ARG(err));
this->next_layer_.handle_error(err); this->next_layer_.handle_error(err);
} }
return false; return err;
} }
} }
return true; return none;
} }
write_queue_type write_queue_; write_queue_type write_queue_;
......
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