stats: support multiple works for error counters
The current code only allowed access to the main thread error counters.
That is not so useful for a multi worker instance.
No return a vector indexed by thread of counter_t values.
Type: fix
Change-Id: Ie322c8889c0c8175e1116e71de04a2cf453b9ed7
Signed-off-by: Ole Troan <ot@cisco.com>
diff --git a/src/vpp-api/client/stat_client.c b/src/vpp-api/client/stat_client.c
index a386eec..8991806 100644
--- a/src/vpp-api/client/stat_client.c
+++ b/src/vpp-api/client/stat_client.c
@@ -231,7 +231,6 @@
int i;
vlib_counter_t **combined_c; /* Combined counter */
counter_t **simple_c; /* Simple counter */
- counter_t *error_base;
uint64_t *offset_vector;
assert (sm->shared_header);
@@ -275,10 +274,16 @@
break;
case STAT_DIR_TYPE_ERROR_INDEX:
- error_base =
- stat_segment_pointer (sm->shared_header,
- sm->shared_header->error_offset);
- result.error_value = error_base[ep->index];
+ /* Gather errors from all threads into a vector */
+ offset_vector = stat_segment_pointer (sm->shared_header,
+ sm->shared_header->error_offset);
+ vec_validate (result.error_vector, vec_len (offset_vector) - 1);
+ for (i = 0; i < vec_len (offset_vector); i++)
+ {
+ counter_t *cb =
+ stat_segment_pointer (sm->shared_header, offset_vector[i]);
+ result.error_vector[i] = cb[ep->index];
+ }
break;
case STAT_DIR_TYPE_NAME_VECTOR: