Skip to content

Commit

Permalink
fixes bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
balazsracz committed Nov 14, 2020
1 parent 4116fcc commit 3cde763
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/openlcb/BulkAliasAllocator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class BulkAliasAllocator : public CallableFlow<BulkAliasRequest>
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.
Expand All @@ -95,6 +95,8 @@ class BulkAliasAllocator : public CallableFlow<BulkAliasRequest>
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())
Expand All @@ -106,7 +108,7 @@ class BulkAliasAllocator : public CallableFlow<BulkAliasRequest>
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 =
Expand All @@ -130,6 +132,7 @@ class BulkAliasAllocator : public CallableFlow<BulkAliasRequest>
}
else
{
bn_.notify();
// Wait for outgoing frames to be gone and call this again.
return wait();
}
Expand Down Expand Up @@ -232,4 +235,10 @@ class BulkAliasAllocator : public CallableFlow<BulkAliasRequest>
uint16_t nextToClaim_;
};

std::unique_ptr<BulkAliasAllocatorInterface> create_bulk_alias_allocator(
IfCan *can_if) {
return std::make_unique<BulkAliasAllocator>(can_if);
}


} // namespace openlcb

0 comments on commit 3cde763

Please sign in to comment.