stats: fix race conditions in vpp-api stats client 18/32918/2
authorArthur de Kerhor <arthurdekerhor@gmail.com>
Thu, 24 Jun 2021 17:39:44 +0000 (19:39 +0200)
committerDave Wallace <dwallacelf@gmail.com>
Fri, 25 Jun 2021 12:35:55 +0000 (08:35 -0400)
Type: fix

Signed-off-by: Arthur de Kerhor <arthurdekerhor@gmail.com>
Signed-off-by: Dave Wallace <dwallacelf@gmail.com>
Change-Id: Ie5c197f6ec0d41d5e405b22662701d83ad94d29e
(cherry picked from commit c9ae8cfaccd75fbc2dc27bdebccdbd14fc0cb60c)

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

index 884a300..376eb8c 100755 (executable)
@@ -187,12 +187,12 @@ class VPPStats():
         while True:
             try:
                 with self.lock:
+                    self.last_epoch = self.epoch
                     for i, direntry in enumerate(StatsVector(self, self.directory_vector, self.elementfmt)):
                         path_raw = direntry[2].find(b'\x00')
                         path = direntry[2][:path_raw].decode('ascii')
                         directory[path] = StatsEntry(direntry[0], direntry[1])
                         directory_by_idx[i] = path
-                    self.last_epoch = self.epoch
                     self.directory = directory
                     self.directory_by_idx = directory_by_idx