Commit b4a34ae9 authored by Joseph Noir's avatar Joseph Noir

Fix some basp tests that use datagram components

parent 3996b8d4
...@@ -130,6 +130,9 @@ public: ...@@ -130,6 +130,9 @@ public:
/// Returns the output buffer of the datagram source identified by `hdl`. /// Returns the output buffer of the datagram source identified by `hdl`.
buffer_type& output_buffer(dgram_scribe_handle hdl); buffer_type& output_buffer(dgram_scribe_handle hdl);
/// Returns complete deque of messages
std::deque<buffer_type>& output_queue(dgram_scribe_handle hdl);
/// Returns the input buffer of the scribe identified by `hdl`. /// Returns the input buffer of the scribe identified by `hdl`.
buffer_type& input_buffer(dgram_scribe_handle hdl); buffer_type& input_buffer(dgram_scribe_handle hdl);
...@@ -212,7 +215,8 @@ public: ...@@ -212,7 +215,8 @@ public:
bool has_pending_scribe(std::string host, uint16_t port); bool has_pending_scribe(std::string host, uint16_t port);
/// Stores `hdl` as a pending endpoint for `src`. /// Stores `hdl` as a pending endpoint for `src`.
void add_pending_endpoints(dgram_doorman_handle src, dgram_scribe_handle hdl); /// Although no transport connection is buid, the nameing eases testing.
void add_pending_connect(dgram_doorman_handle src, dgram_scribe_handle hdl);
using pending_endpoints_map = std::unordered_multimap<dgram_doorman_handle, using pending_endpoints_map = std::unordered_multimap<dgram_doorman_handle,
dgram_scribe_handle>; dgram_scribe_handle>;
...@@ -232,7 +236,7 @@ public: ...@@ -232,7 +236,7 @@ public:
/// Accepts a pending connect on `hdl`. /// Accepts a pending connect on `hdl`.
bool accept_connection(accept_handle hdl); bool accept_connection(accept_handle hdl);
bool accept_endpoint(dgram_doorman_handle hdl); bool accept_connection(dgram_doorman_handle hdl);
/// Reads data from the external input buffer until /// Reads data from the external input buffer until
/// the configured read policy no longer allows receiving. /// the configured read policy no longer allows receiving.
...@@ -298,6 +302,8 @@ private: ...@@ -298,6 +302,8 @@ private:
uint16_t local_port; uint16_t local_port;
std::deque<buffer_type> xbuf; std::deque<buffer_type> xbuf;
std::deque<buffer_type> wr_buf; std::deque<buffer_type> wr_buf;
//buffer_type xbuf;
//buffer_type wr_buf;
buffer_type rd_buf; buffer_type rd_buf;
size_t rcv_buffer_size = 1500; size_t rcv_buffer_size = 1500;
bool stopped_reading = false; bool stopped_reading = false;
...@@ -310,6 +316,7 @@ private: ...@@ -310,6 +316,7 @@ private:
uint16_t remote_port; uint16_t remote_port;
uint16_t local_port; uint16_t local_port;
std::deque<buffer_type> xbuf; std::deque<buffer_type> xbuf;
//buffer_type xbuf;
buffer_type rd_buf; buffer_type rd_buf;
size_t rcv_buffer_size = 1500; size_t rcv_buffer_size = 1500;
bool stopped_reading = false; bool stopped_reading = false;
......
...@@ -274,7 +274,8 @@ expected<void> test_multiplexer::assign_dgram_scribe(abstract_broker* ptr, ...@@ -274,7 +274,8 @@ expected<void> test_multiplexer::assign_dgram_scribe(abstract_broker* ptr,
} }
uint16_t port() const override { uint16_t port() const override {
return mpx_->port(hdl()); //return mpx_->port(hdl());
return static_cast<uint16_t>(hdl().id());
} }
void flush() override { void flush() override {
...@@ -293,6 +294,7 @@ expected<void> test_multiplexer::assign_dgram_scribe(abstract_broker* ptr, ...@@ -293,6 +294,7 @@ expected<void> test_multiplexer::assign_dgram_scribe(abstract_broker* ptr,
test_multiplexer* mpx_; test_multiplexer* mpx_;
}; };
auto dsptr = make_counted<impl>(ptr, hdl, this); auto dsptr = make_counted<impl>(ptr, hdl, this);
impl_ptr(hdl) = dsptr;
ptr->add_dgram_scribe(dsptr); ptr->add_dgram_scribe(dsptr);
return unit; return unit;
} }
...@@ -396,8 +398,9 @@ expected<void> test_multiplexer::assign_dgram_doorman(abstract_broker* ptr, ...@@ -396,8 +398,9 @@ expected<void> test_multiplexer::assign_dgram_doorman(abstract_broker* ptr,
private: private:
test_multiplexer* mpx_; test_multiplexer* mpx_;
}; };
auto dsptr = make_counted<impl>(ptr, hdl, this); auto ddptr = make_counted<impl>(ptr, hdl, this);
ptr->add_dgram_doorman(dsptr); impl_ptr(hdl) = ddptr;
ptr->add_dgram_doorman(ddptr);
return unit; return unit;
} }
...@@ -449,8 +452,9 @@ void test_multiplexer::provide_dgram_scribe(std::string host, ...@@ -449,8 +452,9 @@ void test_multiplexer::provide_dgram_scribe(std::string host,
void test_multiplexer::provide_dgram_doorman(uint16_t desired_port, void test_multiplexer::provide_dgram_doorman(uint16_t desired_port,
dgram_doorman_handle hdl) { dgram_doorman_handle hdl) {
dgram_doormen_.emplace(std::make_pair(desired_port, hdl)); dgram_doormen_.emplace(desired_port, hdl);
dgram_doorman_data_[hdl].remote_port = desired_port; dgram_doorman_data_[hdl].remote_port = desired_port;
dgram_doorman_data_[hdl].local_port = desired_port;
} }
/// The external input buffer should be filled by /// The external input buffer should be filled by
...@@ -520,6 +524,11 @@ test_multiplexer::output_buffer(dgram_scribe_handle hdl) { ...@@ -520,6 +524,11 @@ test_multiplexer::output_buffer(dgram_scribe_handle hdl) {
return buf.back(); return buf.back();
} }
std::deque<test_multiplexer::buffer_type>&
test_multiplexer::output_queue(dgram_scribe_handle hdl) {
return dgram_scribe_data_[hdl].wr_buf;
}
bool& test_multiplexer::stopped_reading(dgram_scribe_handle hdl) { bool& test_multiplexer::stopped_reading(dgram_scribe_handle hdl) {
return dgram_scribe_data_[hdl].stopped_reading; return dgram_scribe_data_[hdl].stopped_reading;
} }
...@@ -596,7 +605,7 @@ void test_multiplexer::add_pending_connect(accept_handle src, ...@@ -596,7 +605,7 @@ void test_multiplexer::add_pending_connect(accept_handle src,
pending_connects_.emplace(src, hdl); pending_connects_.emplace(src, hdl);
} }
void test_multiplexer::add_pending_endpoints(dgram_doorman_handle src, void test_multiplexer::add_pending_connect(dgram_doorman_handle src,
dgram_scribe_handle hdl) { dgram_scribe_handle hdl) {
pending_endpoints_.emplace(src, hdl); pending_endpoints_.emplace(src, hdl);
} }
...@@ -630,13 +639,12 @@ bool test_multiplexer::accept_connection(accept_handle hdl) { ...@@ -630,13 +639,12 @@ bool test_multiplexer::accept_connection(accept_handle hdl) {
return true; return true;
} }
bool test_multiplexer::accept_endpoint(dgram_doorman_handle hdl) { bool test_multiplexer::accept_connection(dgram_doorman_handle hdl) {
if (passive_mode(hdl)) if (passive_mode(hdl))
return false; return false;
auto& dd = dgram_doorman_data_[hdl]; auto& dd = dgram_doorman_data_[hdl];
if (!dd.ptr) if (!dd.ptr)
return false; return false;
// TODO: Is this the right new_enpoint call?
if (!dd.ptr->new_endpoint(dd.rd_buf.data(), dd.rd_buf.size())) if (!dd.ptr->new_endpoint(dd.rd_buf.data(), dd.rd_buf.size()))
passive_mode(hdl) = true; passive_mode(hdl) = true;
return true; return true;
......
This diff is collapsed.
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