From 3cde76305ad22fff9581a19ddea57beee3fcdd75 Mon Sep 17 00:00:00 2001 From: Balazs Racz Date: Sat, 14 Nov 2020 23:24:15 +0100 Subject: [PATCH] fixes bugs --- src/openlcb/BulkAliasAllocator.cxx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/openlcb/BulkAliasAllocator.cxx b/src/openlcb/BulkAliasAllocator.cxx index 32956249c..c19e5855e 100644 --- a/src/openlcb/BulkAliasAllocator.cxx +++ b/src/openlcb/BulkAliasAllocator.cxx @@ -79,7 +79,7 @@ class BulkAliasAllocator : public CallableFlow pendingAliasesByKey_.insert({next_alias}); } bn_.notify(); - return call_immediately(STATE(wait_for_results)); + return wait_and_call(STATE(stamp_time)); } /// Adds the timestamps when the CID requests were sent out. @@ -95,6 +95,8 @@ class BulkAliasAllocator : public CallableFlow return call_immediately(STATE(send_cid_frames)); } + /// Sends out the RID frames for any alias that the 200 msec has already + /// elapsed, then waits a bit and tries again. Action wait_for_results() { if (nextToClaim_ == pendingAliasesByTime_.size()) @@ -106,7 +108,7 @@ class BulkAliasAllocator : public CallableFlow bn_.reset(this); while ((nextToClaim_ < pendingAliasesByTime_.size()) && (num_sent < (unsigned)(config_bulk_alias_num_can_frames())) && - (pendingAliasesByTime_[nextToClaim_].cidTime_ + ALLOCATE_DELAY > + (pendingAliasesByTime_[nextToClaim_].cidTime_ + ALLOCATE_DELAY < ctime)) { NodeAlias a = @@ -130,6 +132,7 @@ class BulkAliasAllocator : public CallableFlow } else { + bn_.notify(); // Wait for outgoing frames to be gone and call this again. return wait(); } @@ -232,4 +235,10 @@ class BulkAliasAllocator : public CallableFlow uint16_t nextToClaim_; }; +std::unique_ptr create_bulk_alias_allocator( + IfCan *can_if) { + return std::make_unique(can_if); +} + + } // namespace openlcb