diff options
-rw-r--r-- | TODO-RELEASE | 1 | ||||
-rw-r--r-- | include/osmocom/core/stat_item.h | 4 | ||||
-rw-r--r-- | src/stats.c | 7 | ||||
-rw-r--r-- | tests/stats/stats_test.c | 2 | ||||
-rw-r--r-- | tests/stats/stats_test.err | 2 |
5 files changed, 15 insertions, 1 deletions
diff --git a/TODO-RELEASE b/TODO-RELEASE index 260e1d4a..c8966cd3 100644 --- a/TODO-RELEASE +++ b/TODO-RELEASE @@ -15,3 +15,4 @@ libosmovty vty_read_config_filep New API libosmosim osim_card_{reset,close} New API libosmocore struct rate_ctr_group, osmo_stat_item_group_desc ABI breakage due to new struct members libosmgsm kdf functions New API +libosmocore osmo_stat_item ABI + API breakage due to new struct members diff --git a/include/osmocom/core/stat_item.h b/include/osmocom/core/stat_item.h index fbe04332..332bbe92 100644 --- a/include/osmocom/core/stat_item.h +++ b/include/osmocom/core/stat_item.h @@ -28,6 +28,10 @@ struct osmo_stat_item { * be read from the FIFO. If accessing osmo_stat_item directly, without * the stats API, store this value elsewhere. */ int32_t stats_next_id; + /* internal use by stats API: indicate if the last value sent to + * reporters was actually the last value in the FIFO. This may not be + * the case, as always a max of 1 or more values gets sent (OS#5215) */ + bool stats_last_sent_was_max; /*! the index of the last value written to the FIFO */ int16_t last_offs; /*! value FIFO */ diff --git a/src/stats.c b/src/stats.c index 411ecff9..f06515dd 100644 --- a/src/stats.c +++ b/src/stats.c @@ -715,6 +715,11 @@ static int osmo_stat_item_handler( if (!have_value) { /* Send the last value in case a flush is requested */ value = osmo_stat_item_get_last(item); + + /* Also send it in case a different max value was sent + * previously (OS#5215) */ + if (!item->stats_last_sent_was_max) + have_value = 1; } else { int32_t next_val; /* If we have multiple values only send the max */ @@ -722,6 +727,8 @@ static int osmo_stat_item_handler( value = OSMO_MAX(value, next_val); } + item->stats_last_sent_was_max = (osmo_stat_item_get_last(item) == value); + llist_for_each_entry(srep, &osmo_stats_reporter_list, list) { if (!srep->running) continue; diff --git a/tests/stats/stats_test.c b/tests/stats/stats_test.c index 6505e669..2f2c6ecc 100644 --- a/tests/stats/stats_test.c +++ b/tests/stats/stats_test.c @@ -445,7 +445,7 @@ static void test_reporting() fprintf(stderr, "report (group 1, item 1 no update, send last item (!= last max), OS#5215):\n"); send_count = 0; osmo_stats_report(); - OSMO_ASSERT(send_count == 0); /* BUG: should be 2! */ + OSMO_ASSERT(send_count == 2); fprintf(stderr, "report (group 1, item 1 no update, nothing to send):\n"); send_count = 0; diff --git a/tests/stats/stats_test.err b/tests/stats/stats_test.err index 08c2cbcd..daa3e5ce 100644 --- a/tests/stats/stats_test.err +++ b/tests/stats/stats_test.err @@ -116,6 +116,8 @@ report (group 1, item 1 update twice, check max): test2: item p= g=test.one i=1 n=item.a v=20 u=ma test1: item p= g=test.one i=1 n=item.a v=20 u=ma report (group 1, item 1 no update, send last item (!= last max), OS#5215): + test2: item p= g=test.one i=1 n=item.a v=10 u=ma + test1: item p= g=test.one i=1 n=item.a v=10 u=ma report (group 1, item 1 no update, nothing to send): report (remove statg1, ctrg1): test2: counter p= g=ctr-test:one_dot i=3 n=ctr:a v=0 d=0 |