2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-31 14:05:33 +00:00

[4254] Merged #4263 fix

This commit is contained in:
Francis Dupont
2016-01-20 14:23:04 +01:00
parent 05a27c9799
commit 992f481916
2 changed files with 28 additions and 11 deletions

View File

@@ -22,6 +22,7 @@
#include <iostream>
#include <map>
#include <queue>
namespace isc {
@@ -250,6 +251,9 @@ public:
/// Packet list iterator to access packets using transaction id hash.
typedef typename PktListTransidHashIndex::const_iterator
PktListTransidHashIterator;
/// Packet list iterator queue for removal.
typedef typename std::queue<PktListTransidHashIterator>
PktListRemovalQueue;
/// \brief Constructor
///
@@ -438,6 +442,8 @@ public:
// bucket size the better. If bucket sizes appear to big we
// might want to increase number of buckets.
unordered_lookup_size_sum_ += std::distance(p.first, p.second);
// Removal can be done only after the loop
PktListRemovalQueue to_remove;
for (PktListTransidHashIterator it = p.first; it != p.second;
++it) {
if ((*it)->getTransid() == rcvd_packet->getTransid()) {
@@ -455,19 +461,30 @@ public:
(static_cast<double>(packet_period.length().fractional_seconds())
/ packet_period.length().ticks_per_second());
if (drop_time_ > 0 && (period_fractional > drop_time_)) {
// The packet pointed to by 'it' is timed out so we
// have to remove it. Removal may invalidate the
// next_sent_ pointer if it points to the packet
// being removed. So, we set the next_sent_ to point
// to the next packet after removed one. This
// pointer will be further updated in the following
// iterations, if the subsequent packets are also
// timed out.
next_sent_ = eraseSent(sent_packets_.template project<0>(it));
++collected_;
// Push the iterator on the removal queue.
to_remove.push(it);
}
}
}
// Deal with the removal queue
while (!to_remove.empty()) {
PktListTransidHashIterator it = to_remove.front();
to_remove.pop();
// The packet pointed to by 'it' is timed out so
// we have to remove it.
if (packet_found || !to_remove.empty()) {
eraseSent(sent_packets_.template project<0>(it));
} else {
// Removal may invalidate the next_sent_
// pointer if it points to the packet being
// removed. So, we set the next_sent_ to point
// to the next packet after removed one.
next_sent_ = eraseSent(sent_packets_.template project<0>(it));
}
++collected_;
}
}
if (!packet_found) {

View File

@@ -68,7 +68,7 @@ public:
255, 255, 255, 255, // giaddr
};
// cppcheck-suppress variableScope
// cppcheck-suppress variableScope
uint8_t v4Opts[] = {
DHO_HOST_NAME, 3, 0, 1, 2, // Host name option.
DHO_BOOT_SIZE, 3, 10, 11, 12, // Boot file size option