MINOR: freq_ctr: unify freq_ctr and freq_ctr_period into freq_ctr
Both structures are identical except the name of the field starting
the period and its description. Let's call them all freq_ctr and the
period's start "curr_tick" which is generic.
This is only a temporary change and fields are expected to remain
the same with no code change (verified).
diff --git a/src/freq_ctr.c b/src/freq_ctr.c
index d68a784..3d14163 100644
--- a/src/freq_ctr.c
+++ b/src/freq_ctr.c
@@ -37,7 +37,7 @@
__ha_compiler_barrier();
_past = ctr->prev_ctr;
__ha_compiler_barrier();
- _curr_sec = ctr->curr_sec;
+ _curr_sec = ctr->curr_tick;
__ha_compiler_barrier();
if (_curr_sec & 0x80000000)
continue;
@@ -45,7 +45,7 @@
__ha_compiler_barrier();
past = ctr->prev_ctr;
__ha_compiler_barrier();
- curr_sec = ctr->curr_sec;
+ curr_sec = ctr->curr_tick;
__ha_compiler_barrier();
if (_curr == curr && _past == past && _curr_sec == curr_sec)
break;
@@ -80,7 +80,7 @@
__ha_compiler_barrier();
_past = ctr->prev_ctr;
__ha_compiler_barrier();
- _curr_sec = ctr->curr_sec;
+ _curr_sec = ctr->curr_tick;
__ha_compiler_barrier();
if (_curr_sec & 0x80000000)
continue;
@@ -88,7 +88,7 @@
__ha_compiler_barrier();
past = ctr->prev_ctr;
__ha_compiler_barrier();
- curr_sec = ctr->curr_sec;
+ curr_sec = ctr->curr_tick;
__ha_compiler_barrier();
if (_curr == curr && _past == past && _curr_sec == curr_sec)
break;
@@ -127,7 +127,7 @@
__ha_compiler_barrier();
_past = ctr->prev_ctr;
__ha_compiler_barrier();
- _curr_sec = ctr->curr_sec;
+ _curr_sec = ctr->curr_tick;
__ha_compiler_barrier();
if (_curr_sec & 0x80000000)
continue;
@@ -135,7 +135,7 @@
__ha_compiler_barrier();
past = ctr->prev_ctr;
__ha_compiler_barrier();
- curr_sec = ctr->curr_sec;
+ curr_sec = ctr->curr_tick;
__ha_compiler_barrier();
if (_curr == curr && _past == past && _curr_sec == curr_sec)
break;
@@ -176,7 +176,7 @@
* read_freq_ctr_period() to avoid reporting ups and downs on low-frequency
* events when the past value is <= 1.
*/
-ullong freq_ctr_total(struct freq_ctr_period *ctr, uint period, int pend)
+ullong freq_ctr_total(struct freq_ctr *ctr, uint period, int pend)
{
ullong curr, past;
uint curr_tick;
diff --git a/src/peers.c b/src/peers.c
index dd3d9dd..2ebb107 100644
--- a/src/peers.c
+++ b/src/peers.c
@@ -713,7 +713,7 @@
break;
}
case STD_T_FRQP: {
- struct freq_ctr_period *frqp;
+ struct freq_ctr *frqp;
frqp = &stktable_data_cast(data_ptr, std_t_frqp);
intencode((unsigned int)(now_ms - frqp->curr_tick), &cursor);
@@ -1667,11 +1667,11 @@
break;
case STD_T_FRQP: {
- struct freq_ctr_period data;
+ struct freq_ctr data;
- /* First bit is reserved for the freq_ctr_period lock
+ /* First bit is reserved for the freq_ctr lock
Note: here we're still protected by the stksess lock
- so we don't need to update the update the freq_ctr_period
+ so we don't need to update the update the freq_ctr
using its internal lock */
data.curr_tick = tick_add(now_ms, -decoded_int) & ~0x1;
diff --git a/src/stick_table.c b/src/stick_table.c
index e305a44..1fe60a0 100644
--- a/src/stick_table.c
+++ b/src/stick_table.c
@@ -3627,7 +3627,7 @@
int data_type;
int cur_arg;
void *ptr;
- struct freq_ctr_period *frqp;
+ struct freq_ctr *frqp;
if (!*args[4])
return cli_err(appctx, "Key value expected\n");
@@ -3764,9 +3764,9 @@
* push measures without having to update them too often.
*/
frqp = &stktable_data_cast(ptr, std_t_frqp);
- /* First bit is reserved for the freq_ctr_period lock
+ /* First bit is reserved for the freq_ctr lock
Note: here we're still protected by the stksess lock
- so we don't need to update the update the freq_ctr_period
+ so we don't need to update the update the freq_ctr
using its internal lock */
frqp->curr_tick = now_ms & ~0x1;
frqp->prev_ctr = 0;
diff --git a/src/stream.c b/src/stream.c
index bdc974c..6c60cd4 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -424,7 +424,7 @@
s->buffer_wait.target = s;
s->buffer_wait.wakeup_cb = stream_buf_available;
- s->call_rate.curr_sec = s->call_rate.curr_ctr = s->call_rate.prev_ctr = 0;
+ s->call_rate.curr_tick = s->call_rate.curr_ctr = s->call_rate.prev_ctr = 0;
s->pcli_next_pid = 0;
s->pcli_flags = 0;
s->unique_id = IST_NULL;