stats: catch stat segment overrun in retry loop 13/32313/6
authorOle Troan <ot@cisco.com>
Fri, 14 May 2021 12:00:50 +0000 (14:00 +0200)
committerDamjan Marion <dmarion@me.com>
Fri, 21 May 2021 21:07:38 +0000 (21:07 +0000)
Raise IOError so that the blocking code retries not only on
optimistic locking failures but also on data segment illegal reads.

Type: fix
Signed-off-by: Ole Troan <ot@cisco.com>
Change-Id: I6bb250e239486b60192004271c1690e790513318

src/vpp-api/python/vpp_papi/vpp_stats.py

index 821a413..884a300 100755 (executable)
@@ -69,7 +69,7 @@ def get_string(stats, ptr):
     namevector = ptr - stats.base
     namevectorlen = get_vec_len(stats, namevector)
     if namevector + namevectorlen >= stats.size:
-        raise ValueError('String overruns stats segment')
+        raise IOError('String overruns stats segment')
     return stats.statseg[namevector:namevector+namevectorlen-1].decode('ascii')
 
 
@@ -86,7 +86,7 @@ class StatsVector:
         self.stats = stats
 
         if self.vec_start + self.vec_len * self.elementsize >= stats.size:
-            raise ValueError('Vector overruns stats segment')
+            raise IOError('Vector overruns stats segment')
 
     def __iter__(self):
         with self.stats.lock:
@@ -95,7 +95,7 @@ class StatsVector:
 
     def __getitem__(self, index):
         if index > self.vec_len:
-            raise ValueError('Index beyond end of vector')
+            raise IOError('Index beyond end of vector')
         with self.stats.lock:
             if self.fmtlen == 1:
                 return self.struct.unpack_from(self.statseg, self.vec_start +