summaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorArne H Juul <arnej@yahooinc.com>2022-03-23 13:07:29 +0000
committerArne H Juul <arnej@yahooinc.com>2022-03-23 13:07:34 +0000
commit1a2bf75a4f301bb0481141ee23ff03f4050921b7 (patch)
treeea76ed6555a39c869fae9a2d5d7afc9310abfaed /config
parentc4860985003377b22ec033636551130a70f97eb5 (diff)
add some sanity checking
Diffstat (limited to 'config')
-rw-r--r--config/src/vespa/config/frt/frtconnectionpool.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/config/src/vespa/config/frt/frtconnectionpool.cpp b/config/src/vespa/config/frt/frtconnectionpool.cpp
index 2ae812cd76e..0c11401e052 100644
--- a/config/src/vespa/config/frt/frtconnectionpool.cpp
+++ b/config/src/vespa/config/frt/frtconnectionpool.cpp
@@ -73,11 +73,13 @@ FRTConnectionPool::getNextRoundRobin()
FRTConnection* nextFRTConnection = nullptr;
if ( ! ready.empty()) {
- int sel = _selectIdx % (int)ready.size();
+ unsigned int sel = _selectIdx % (int)ready.size();
+ LOG_ASSERT(sel < ready.size());
_selectIdx = sel + 1;
nextFRTConnection = ready[sel];
} else if ( ! suspended.empty()) {
- int sel = _selectIdx % (int)suspended.size();
+ unsigned int sel = _selectIdx % (int)suspended.size();
+ LOG_ASSERT(sel < suspended.size());
_selectIdx = sel + 1;
nextFRTConnection = suspended[sel];
}
@@ -113,10 +115,12 @@ FRTConnectionPool::getNextHashBased()
FRTConnection* nextFRTConnection = nullptr;
if ( ! ready.empty()) {
- int sel = std::abs(hashCode(_hostname) % (int)ready.size());
+ unsigned int sel = std::abs(hashCode(_hostname) % (int)ready.size());
+ LOG_ASSERT(sel < ready.size());
nextFRTConnection = ready[sel];
} else if ( ! suspended.empty() ){
- int sel = std::abs(hashCode(_hostname) % (int)suspended.size());
+ unsigned int sel = std::abs(hashCode(_hostname) % (int)suspended.size());
+ LOG_ASSERT(sel < suspended.size());
nextFRTConnection = suspended[sel];
}
return nextFRTConnection;