* be easily performed. If the inspected parameter is not stored in the table,
* <not found> is returned.
*/
+static int smp_fetch_bytes_in_rate(struct stkctr *stkctr, struct sample *smp, int decrefcnt);
static int sample_conv_table_bytes_in_rate(const struct arg *arg_p, struct sample *smp, void *private)
{
- struct stktable *t;
- struct stksess *ts;
- void *ptr;
-
- t = arg_p[0].data.t;
-
- ts = smp_fetch_stksess(t, smp, 0);
-
- smp->flags = SMP_F_VOL_TEST;
- smp->data.type = SMP_T_SINT;
- smp->data.u.sint = 0;
-
- if (!ts) /* key not present */
- return 1;
-
- ptr = stktable_data_ptr(t, ts, STKTABLE_DT_BYTES_IN_RATE);
- if (ptr) {
- HA_RWLOCK_RDLOCK(STK_SESS_LOCK, &ts->lock);
-
- smp->data.u.sint = (uint64_t)read_freq_ctr_period(&stktable_data_cast(ptr, std_t_frqp),
- t->data_arg[STKTABLE_DT_BYTES_IN_RATE].u) * t->brates_factor;
+ struct stkctr stkctr;
- HA_RWLOCK_RDUNLOCK(STK_SESS_LOCK, &ts->lock);
- }
+ stkctr.table = arg_p[0].data.t;
+ stkctr_set_entry(&stkctr, smp_fetch_stksess(stkctr.table, smp, 0));
- stktable_release(t, ts);
- return !!ptr;
+ return smp_fetch_bytes_in_rate(&stkctr, smp, 1);
}
/* Casts sample <smp> to the type of the table specified in arg(0), and looks
* be easily performed. If the inspected parameter is not stored in the table,
* <not found> is returned.
*/
+static int smp_fetch_conn_cnt(struct stkctr *stkctr, struct sample *smp, int decrefcnt);
static int sample_conv_table_conn_cnt(const struct arg *arg_p, struct sample *smp, void *private)
{
- struct stktable *t;
- struct stksess *ts;
- void *ptr;
-
- t = arg_p[0].data.t;
-
- ts = smp_fetch_stksess(t, smp, 0);
-
- smp->flags = SMP_F_VOL_TEST;
- smp->data.type = SMP_T_SINT;
- smp->data.u.sint = 0;
-
- if (!ts) /* key not present */
- return 1;
-
- ptr = stktable_data_ptr(t, ts, STKTABLE_DT_CONN_CNT);
- if (ptr) {
- HA_RWLOCK_RDLOCK(STK_SESS_LOCK, &ts->lock);
+ struct stkctr stkctr;
- smp->data.u.sint = stktable_data_cast(ptr, std_t_uint);
-
- HA_RWLOCK_RDUNLOCK(STK_SESS_LOCK, &ts->lock);
- }
+ stkctr.table = arg_p[0].data.t;
+ stkctr_set_entry(&stkctr, smp_fetch_stksess(stkctr.table, smp, 0));
- stktable_release(t, ts);
- return !!ptr;
+ return smp_fetch_conn_cnt(&stkctr, smp, 1);
}
/* Casts sample <smp> to the type of the table specified in arg(0), and looks
* can be easily performed. If the inspected parameter is not stored in the
* table, <not found> is returned.
*/
+static int smp_fetch_conn_cur(struct stkctr *stkctr, struct sample *smp, int decrefcnt);
static int sample_conv_table_conn_cur(const struct arg *arg_p, struct sample *smp, void *private)
{
- struct stktable *t;
- struct stksess *ts;
- void *ptr;
-
- t = arg_p[0].data.t;
-
- ts = smp_fetch_stksess(t, smp, 0);
-
- smp->flags = SMP_F_VOL_TEST;
- smp->data.type = SMP_T_SINT;
- smp->data.u.sint = 0;
-
- if (!ts) /* key not present */
- return 1;
-
- ptr = stktable_data_ptr(t, ts, STKTABLE_DT_CONN_CUR);
- if (ptr) {
- HA_RWLOCK_RDLOCK(STK_SESS_LOCK, &ts->lock);
-
- smp->data.u.sint = stktable_data_cast(ptr, std_t_uint);
+ struct stkctr stkctr;
- HA_RWLOCK_RDUNLOCK(STK_SESS_LOCK, &ts->lock);
- }
+ stkctr.table = arg_p[0].data.t;
+ stkctr_set_entry(&stkctr, smp_fetch_stksess(stkctr.table, smp, 0));
- stktable_release(t, ts);
- return !!ptr;
+ return smp_fetch_conn_cur(&stkctr, smp, 1);
}
/* Casts sample <smp> to the type of the table specified in arg(0), and looks
* be easily performed. If the inspected parameter is not stored in the table,
* <not found> is returned.
*/
+static int smp_fetch_conn_rate(struct stkctr *stkctr, struct sample *smp, int decrefcnt);
static int sample_conv_table_conn_rate(const struct arg *arg_p, struct sample *smp, void *private)
{
- struct stktable *t;
- struct stksess *ts;
- void *ptr;
-
- t = arg_p[0].data.t;
-
- ts = smp_fetch_stksess(t, smp, 0);
-
- smp->flags = SMP_F_VOL_TEST;
- smp->data.type = SMP_T_SINT;
- smp->data.u.sint = 0;
+ struct stkctr stkctr;
- if (!ts) /* key not present */
- return 1;
-
- ptr = stktable_data_ptr(t, ts, STKTABLE_DT_CONN_RATE);
- if (ptr) {
- HA_RWLOCK_RDLOCK(STK_SESS_LOCK, &ts->lock);
-
- smp->data.u.sint = read_freq_ctr_period(&stktable_data_cast(ptr, std_t_frqp),
- t->data_arg[STKTABLE_DT_CONN_RATE].u);
-
- HA_RWLOCK_RDUNLOCK(STK_SESS_LOCK, &ts->lock);
- }
+ stkctr.table = arg_p[0].data.t;
+ stkctr_set_entry(&stkctr, smp_fetch_stksess(stkctr.table, smp, 0));
- stktable_release(t, ts);
- return !!ptr;
+ return smp_fetch_conn_rate(&stkctr, smp, 1);
}
/* Casts sample <smp> to the type of the table specified in arg(0), and looks
* be easily performed. If the inspected parameter is not stored in the table,
* <not found> is returned.
*/
+static int smp_fetch_bytes_out_rate(struct stkctr *stkctr, struct sample *smp, int decrefcnt);
static int sample_conv_table_bytes_out_rate(const struct arg *arg_p, struct sample *smp, void *private)
{
- struct stktable *t;
- struct stksess *ts;
- void *ptr;
-
- t = arg_p[0].data.t;
-
- ts = smp_fetch_stksess(t, smp, 0);
-
- smp->flags = SMP_F_VOL_TEST;
- smp->data.type = SMP_T_SINT;
- smp->data.u.sint = 0;
-
- if (!ts) /* key not present */
- return 1;
-
- ptr = stktable_data_ptr(t, ts, STKTABLE_DT_BYTES_OUT_RATE);
- if (ptr) {
- HA_RWLOCK_RDLOCK(STK_SESS_LOCK, &ts->lock);
-
- smp->data.u.sint = (uint64_t)read_freq_ctr_period(&stktable_data_cast(ptr, std_t_frqp),
- t->data_arg[STKTABLE_DT_BYTES_OUT_RATE].u) * t->brates_factor;
+ struct stkctr stkctr;
- HA_RWLOCK_RDUNLOCK(STK_SESS_LOCK, &ts->lock);
- }
+ stkctr.table = arg_p[0].data.t;
+ stkctr_set_entry(&stkctr, smp_fetch_stksess(stkctr.table, smp, 0));
- stktable_release(t, ts);
- return !!ptr;
+ return smp_fetch_bytes_out_rate(&stkctr, smp, 1);
}
/* Casts sample <smp> to the type of the table specified in arg(0), and looks
* can be easily performed. If the inspected parameter is not stored in the
* table, <not found> is returned.
*/
+static int smp_fetch_glitch_cnt(struct stkctr *stkctr, struct sample *smp, int decrefcnt);
static int sample_conv_table_glitch_cnt(const struct arg *arg_p, struct sample *smp, void *private)
{
- struct stktable *t;
- struct stksess *ts;
- void *ptr;
-
- t = arg_p[0].data.t;
-
- ts = smp_fetch_stksess(t, smp, 0);
-
- smp->flags = SMP_F_VOL_TEST;
- smp->data.type = SMP_T_SINT;
- smp->data.u.sint = 0;
-
- if (!ts) /* key not present */
- return 1;
-
- ptr = stktable_data_ptr(t, ts, STKTABLE_DT_GLITCH_CNT);
- if (ptr) {
- HA_RWLOCK_RDLOCK(STK_SESS_LOCK, &ts->lock);
+ struct stkctr stkctr;
- smp->data.u.sint = stktable_data_cast(ptr, std_t_uint);
-
- HA_RWLOCK_RDUNLOCK(STK_SESS_LOCK, &ts->lock);
- }
+ stkctr.table = arg_p[0].data.t;
+ stkctr_set_entry(&stkctr, smp_fetch_stksess(stkctr.table, smp, 0));
- stktable_release(t, ts);
- return !!ptr;
+ return smp_fetch_glitch_cnt(&stkctr, smp, 1);
}
/* Casts sample <smp> to the type of the table specified in arg(0), and looks
* performed. If the inspected parameter is not stored in the table, <not found>
* is returned.
*/
+static int smp_fetch_glitch_rate(struct stkctr *stkctr, struct sample *smp, int decrefcnt);
static int sample_conv_table_glitch_rate(const struct arg *arg_p, struct sample *smp, void *private)
{
- struct stktable *t;
- struct stksess *ts;
- void *ptr;
-
- t = arg_p[0].data.t;
-
- ts = smp_fetch_stksess(t, smp, 0);
-
- smp->flags = SMP_F_VOL_TEST;
- smp->data.type = SMP_T_SINT;
- smp->data.u.sint = 0;
-
- if (!ts) /* key not present */
- return 1;
+ struct stkctr stkctr;
- ptr = stktable_data_ptr(t, ts, STKTABLE_DT_GLITCH_RATE);
- if (ptr) {
- HA_RWLOCK_RDLOCK(STK_SESS_LOCK, &ts->lock);
-
- smp->data.u.sint = read_freq_ctr_period(&stktable_data_cast(ptr, std_t_frqp),
- t->data_arg[STKTABLE_DT_GLITCH_RATE].u);
+ stkctr.table = arg_p[0].data.t;
+ stkctr_set_entry(&stkctr, smp_fetch_stksess(stkctr.table, smp, 0));
- HA_RWLOCK_RDUNLOCK(STK_SESS_LOCK, &ts->lock);
- }
-
- stktable_release(t, ts);
- return !!ptr;
+ return smp_fetch_glitch_rate(&stkctr, smp, 1);
}
/* Casts sample <smp> to the type of the table specified in arg_p(1), and looks
* be easily performed. If the inspected parameter is not stored in the table,
* <not found> is returned.
*/
+static int smp_fetch_get_gpt(struct stkctr *stkctr, struct sample *smp, unsigned int idx, int decrefcnt);
static int sample_conv_table_gpt(const struct arg *arg_p, struct sample *smp, void *private)
{
- struct stktable *t;
- struct stksess *ts;
- void *ptr;
+ struct stkctr stkctr;
unsigned int idx;
idx = arg_p[0].data.sint;
+ stkctr.table = arg_p[1].data.t;
+ stkctr_set_entry(&stkctr, smp_fetch_stksess(stkctr.table, smp, 0));
- t = arg_p[1].data.t;
-
- ts = smp_fetch_stksess(t, smp, 0);
-
- smp->flags = SMP_F_VOL_TEST;
- smp->data.type = SMP_T_SINT;
- smp->data.u.sint = 0;
-
- if (!ts) /* key not present */
- return 1;
-
- ptr = stktable_data_ptr_idx(t, ts, STKTABLE_DT_GPT, idx);
- if (ptr) {
- HA_RWLOCK_RDLOCK(STK_SESS_LOCK, &ts->lock);
-
- smp->data.u.sint = stktable_data_cast(ptr, std_t_uint);
-
- HA_RWLOCK_RDUNLOCK(STK_SESS_LOCK, &ts->lock);
- }
-
- stktable_release(t, ts);
- return !!ptr;
+ return smp_fetch_get_gpt(&stkctr, smp, idx, 1);
}
/* Casts sample <smp> to the type of the table specified in arg(0), and looks
* be easily performed. If the inspected parameter is not stored in the table,
* <not found> is returned.
*/
+static int smp_fetch_get_gpt0(struct stkctr *stkctr, struct sample *smp, int decrefcnt);
static int sample_conv_table_gpt0(const struct arg *arg_p, struct sample *smp, void *private)
{
- struct stktable *t;
- struct stksess *ts;
- void *ptr;
-
- t = arg_p[0].data.t;
-
- ts = smp_fetch_stksess(t, smp, 0);
-
- smp->flags = SMP_F_VOL_TEST;
- smp->data.type = SMP_T_SINT;
- smp->data.u.sint = 0;
-
- if (!ts) /* key not present */
- return 1;
-
- ptr = stktable_data_ptr(t, ts, STKTABLE_DT_GPT0);
- if (!ptr)
- ptr = stktable_data_ptr_idx(t, ts, STKTABLE_DT_GPT, 0);
+ struct stkctr stkctr;
- if (ptr) {
- HA_RWLOCK_RDLOCK(STK_SESS_LOCK, &ts->lock);
-
- smp->data.u.sint = stktable_data_cast(ptr, std_t_uint);
+ stkctr.table = arg_p[0].data.t;
+ stkctr_set_entry(&stkctr, smp_fetch_stksess(stkctr.table, smp, 0));
- HA_RWLOCK_RDUNLOCK(STK_SESS_LOCK, &ts->lock);
- }
-
- stktable_release(t, ts);
- return !!ptr;
+ return smp_fetch_get_gpt0(&stkctr, smp, 1);
}
/* Casts sample <smp> to the type of the table specified in arg_p(1), and looks
* be easily performed. If the inspected parameter is not stored in the table,
* <not found> is returned.
*/
+static int smp_fetch_get_gpc(struct stkctr *stkctr, struct sample *smp, unsigned int idx, int decrefcnt);
static int sample_conv_table_gpc(const struct arg *arg_p, struct sample *smp, void *private)
{
- struct stktable *t;
- struct stksess *ts;
- void *ptr;
+ struct stkctr stkctr;
unsigned int idx;
idx = arg_p[0].data.sint;
+ stkctr.table = arg_p[1].data.t;
+ stkctr_set_entry(&stkctr, smp_fetch_stksess(stkctr.table, smp, 0));
- t = arg_p[1].data.t;
-
- ts = smp_fetch_stksess(t, smp, 0);
-
- smp->flags = SMP_F_VOL_TEST;
- smp->data.type = SMP_T_SINT;
- smp->data.u.sint = 0;
-
- if (!ts) /* key not present */
- return 1;
-
- ptr = stktable_data_ptr_idx(t, ts, STKTABLE_DT_GPC, idx);
- if (ptr) {
- HA_RWLOCK_RDLOCK(STK_SESS_LOCK, &ts->lock);
-
- smp->data.u.sint = stktable_data_cast(ptr, std_t_uint);
-
- HA_RWLOCK_RDUNLOCK(STK_SESS_LOCK, &ts->lock);
- }
-
- stktable_release(t, ts);
- return !!ptr;
+ return smp_fetch_get_gpc(&stkctr, smp, idx, 1);
}
/* Casts sample <smp> to the type of the table specified in arg_p(1), and looks
* comparisons can be easily performed. If the inspected parameter is not
* stored in the table, <not found> is returned.
*/
+static int smp_fetch_gpc_rate(struct stkctr *stkctr, struct sample *smp, unsigned int idx, int decrefcnt);
static int sample_conv_table_gpc_rate(const struct arg *arg_p, struct sample *smp, void *private)
{
- struct stktable *t;
- struct stksess *ts;
- void *ptr;
+ struct stkctr stkctr;
unsigned int idx;
idx = arg_p[0].data.sint;
+ stkctr.table = arg_p[1].data.t;
+ stkctr_set_entry(&stkctr, smp_fetch_stksess(stkctr.table, smp, 0));
- t = arg_p[1].data.t;
-
- ts = smp_fetch_stksess(t, smp, 0);
-
- smp->flags = SMP_F_VOL_TEST;
- smp->data.type = SMP_T_SINT;
- smp->data.u.sint = 0;
-
- if (!ts) /* key not present */
- return 1;
-
- ptr = stktable_data_ptr_idx(t, ts, STKTABLE_DT_GPC_RATE, idx);
- if (ptr) {
- HA_RWLOCK_RDLOCK(STK_SESS_LOCK, &ts->lock);
-
- smp->data.u.sint = read_freq_ctr_period(&stktable_data_cast(ptr, std_t_frqp),
- t->data_arg[STKTABLE_DT_GPC_RATE].u);
-
- HA_RWLOCK_RDUNLOCK(STK_SESS_LOCK, &ts->lock);
- }
-
- stktable_release(t, ts);
- return !!ptr;
+ return smp_fetch_gpc_rate(&stkctr, smp, idx, 1);
}
/* Casts sample <smp> to the type of the table specified in arg(0), and looks
* be easily performed. If the inspected parameter is not stored in the table,
* <not found> is returned.
*/
+static int smp_fetch_get_gpc0(struct stkctr *stkctr, struct sample *smp, int decrefcnt);
static int sample_conv_table_gpc0(const struct arg *arg_p, struct sample *smp, void *private)
{
- struct stktable *t;
- struct stksess *ts;
- void *ptr;
-
- t = arg_p[0].data.t;
-
- ts = smp_fetch_stksess(t, smp, 0);
-
- smp->flags = SMP_F_VOL_TEST;
- smp->data.type = SMP_T_SINT;
- smp->data.u.sint = 0;
-
- if (!ts) /* key not present */
- return 1;
+ struct stkctr stkctr;
- ptr = stktable_data_ptr(t, ts, STKTABLE_DT_GPC0);
- if (!ptr) {
- /* fallback on the gpc array */
- ptr = stktable_data_ptr_idx(t, ts, STKTABLE_DT_GPC, 0);
- }
+ stkctr.table = arg_p[0].data.t;
+ stkctr_set_entry(&stkctr, smp_fetch_stksess(stkctr.table, smp, 0));
- if (ptr) {
- HA_RWLOCK_RDLOCK(STK_SESS_LOCK, &ts->lock);
-
- smp->data.u.sint = stktable_data_cast(ptr, std_t_uint);
-
- HA_RWLOCK_RDUNLOCK(STK_SESS_LOCK, &ts->lock);
- }
-
- stktable_release(t, ts);
- return !!ptr;
+ return smp_fetch_get_gpc0(&stkctr, smp, 1);
}
/* Casts sample <smp> to the type of the table specified in arg(0), and looks
* be easily performed. If the inspected parameter is not stored in the table,
* <not found> is returned.
*/
+static int smp_fetch_gpc0_rate(struct stkctr *stkctr, struct sample *smp, int decrefcnt);
static int sample_conv_table_gpc0_rate(const struct arg *arg_p, struct sample *smp, void *private)
{
- struct stktable *t;
- struct stksess *ts;
- void *ptr;
-
- t = arg_p[0].data.t;
-
- ts = smp_fetch_stksess(t, smp, 0);
-
- smp->flags = SMP_F_VOL_TEST;
- smp->data.type = SMP_T_SINT;
- smp->data.u.sint = 0;
-
- if (!ts) /* key not present */
- return 1;
-
- ptr = stktable_data_ptr(t, ts, STKTABLE_DT_GPC0_RATE);
- if (ptr) {
- HA_RWLOCK_RDLOCK(STK_SESS_LOCK, &ts->lock);
-
- smp->data.u.sint = read_freq_ctr_period(&stktable_data_cast(ptr, std_t_frqp),
- t->data_arg[STKTABLE_DT_GPC0_RATE].u);
-
- HA_RWLOCK_RDUNLOCK(STK_SESS_LOCK, &ts->lock);
- }
- else {
- /* fallback on the gpc array */
- ptr = stktable_data_ptr_idx(t, ts, STKTABLE_DT_GPC_RATE, 0);
- if (ptr) {
- HA_RWLOCK_RDLOCK(STK_SESS_LOCK, &ts->lock);
+ struct stkctr stkctr;
- smp->data.u.sint = read_freq_ctr_period(&stktable_data_cast(ptr, std_t_frqp),
- t->data_arg[STKTABLE_DT_GPC_RATE].u);
+ stkctr.table = arg_p[0].data.t;
+ stkctr_set_entry(&stkctr, smp_fetch_stksess(stkctr.table, smp, 0));
- HA_RWLOCK_RDUNLOCK(STK_SESS_LOCK, &ts->lock);
- }
- }
-
- stktable_release(t, ts);
- return !!ptr;
+ return smp_fetch_gpc0_rate(&stkctr, smp, 1);
}
/* Casts sample <smp> to the type of the table specified in arg(0), and looks
* be easily performed. If the inspected parameter is not stored in the table,
* <not found> is returned.
*/
+static int smp_fetch_get_gpc1(struct stkctr *stkctr, struct sample *smp, int decrefcnt);
static int sample_conv_table_gpc1(const struct arg *arg_p, struct sample *smp, void *private)
{
- struct stktable *t;
- struct stksess *ts;
- void *ptr;
-
- t = arg_p[0].data.t;
+ struct stkctr stkctr;
- ts = smp_fetch_stksess(t, smp, 0);
-
- smp->flags = SMP_F_VOL_TEST;
- smp->data.type = SMP_T_SINT;
- smp->data.u.sint = 0;
+ stkctr.table = arg_p[0].data.t;
+ stkctr_set_entry(&stkctr, smp_fetch_stksess(stkctr.table, smp, 0));
- if (!ts) /* key not present */
- return 1;
-
- ptr = stktable_data_ptr(t, ts, STKTABLE_DT_GPC1);
- if (!ptr) {
- /* fallback on the gpc array */
- ptr = stktable_data_ptr_idx(t, ts, STKTABLE_DT_GPC, 1);
- }
-
- if (ptr) {
- HA_RWLOCK_RDLOCK(STK_SESS_LOCK, &ts->lock);
-
- smp->data.u.sint = stktable_data_cast(ptr, std_t_uint);
-
- HA_RWLOCK_RDUNLOCK(STK_SESS_LOCK, &ts->lock);
- }
-
- stktable_release(t, ts);
- return !!ptr;
+ return smp_fetch_get_gpc1(&stkctr, smp, 1);
}
/* Casts sample <smp> to the type of the table specified in arg(0), and looks
* be easily performed. If the inspected parameter is not stored in the table,
* <not found> is returned.
*/
+static int smp_fetch_gpc1_rate(struct stkctr *stkctr, struct sample *smp, int decrefcnt);
static int sample_conv_table_gpc1_rate(const struct arg *arg_p, struct sample *smp, void *private)
{
- struct stktable *t;
- struct stksess *ts;
- void *ptr;
+ struct stkctr stkctr;
- t = arg_p[0].data.t;
+ stkctr.table = arg_p[0].data.t;
+ stkctr_set_entry(&stkctr, smp_fetch_stksess(stkctr.table, smp, 0));
- ts = smp_fetch_stksess(t, smp, 0);
-
- smp->flags = SMP_F_VOL_TEST;
- smp->data.type = SMP_T_SINT;
- smp->data.u.sint = 0;
-
- if (!ts) /* key not present */
- return 1;
-
- ptr = stktable_data_ptr(t, ts, STKTABLE_DT_GPC1_RATE);
- if (ptr) {
- HA_RWLOCK_RDLOCK(STK_SESS_LOCK, &ts->lock);
-
- smp->data.u.sint = read_freq_ctr_period(&stktable_data_cast(ptr, std_t_frqp),
- t->data_arg[STKTABLE_DT_GPC1_RATE].u);
-
- HA_RWLOCK_RDUNLOCK(STK_SESS_LOCK, &ts->lock);
- }
- else {
- /* fallback on the gpc array */
- ptr = stktable_data_ptr_idx(t, ts, STKTABLE_DT_GPC_RATE, 1);
- if (ptr) {
- HA_RWLOCK_RDLOCK(STK_SESS_LOCK, &ts->lock);
-
- smp->data.u.sint = read_freq_ctr_period(&stktable_data_cast(ptr, std_t_frqp),
- t->data_arg[STKTABLE_DT_GPC_RATE].u);
-
- HA_RWLOCK_RDUNLOCK(STK_SESS_LOCK, &ts->lock);
- }
- }
-
- stktable_release(t, ts);
- return !!ptr;
+ return smp_fetch_gpc1_rate(&stkctr, smp, 1);
}
/* Casts sample <smp> to the type of the table specified in arg(0), and looks
* comparisons can be easily performed. If the inspected parameter is not stored
* in the table, <not found> is returned.
*/
+static int smp_fetch_http_err_cnt(struct stkctr *stkctr, struct sample *smp, int decrefcnt);
static int sample_conv_table_http_err_cnt(const struct arg *arg_p, struct sample *smp, void *private)
{
- struct stktable *t;
- struct stksess *ts;
- void *ptr;
+ struct stkctr stkctr;
- t = arg_p[0].data.t;
-
- ts = smp_fetch_stksess(t, smp, 0);
-
- smp->flags = SMP_F_VOL_TEST;
- smp->data.type = SMP_T_SINT;
- smp->data.u.sint = 0;
-
- if (!ts) /* key not present */
- return 1;
-
- ptr = stktable_data_ptr(t, ts, STKTABLE_DT_HTTP_ERR_CNT);
- if (ptr) {
- HA_RWLOCK_RDLOCK(STK_SESS_LOCK, &ts->lock);
-
- smp->data.u.sint = stktable_data_cast(ptr, std_t_uint);
+ stkctr.table = arg_p[0].data.t;
+ stkctr_set_entry(&stkctr, smp_fetch_stksess(stkctr.table, smp, 0));
- HA_RWLOCK_RDUNLOCK(STK_SESS_LOCK, &ts->lock);
- }
-
- stktable_release(t, ts);
- return !!ptr;
+ return smp_fetch_http_err_cnt(&stkctr, smp, 1);
}
/* Casts sample <smp> to the type of the table specified in arg(0), and looks
* be easily performed. If the inspected parameter is not stored in the table,
* <not found> is returned.
*/
+static int smp_fetch_http_err_rate(struct stkctr *stkctr, struct sample *smp, int decrefcnt);
static int sample_conv_table_http_err_rate(const struct arg *arg_p, struct sample *smp, void *private)
{
- struct stktable *t;
- struct stksess *ts;
- void *ptr;
-
- t = arg_p[0].data.t;
-
- ts = smp_fetch_stksess(t, smp, 0);
-
- smp->flags = SMP_F_VOL_TEST;
- smp->data.type = SMP_T_SINT;
- smp->data.u.sint = 0;
-
- if (!ts) /* key not present */
- return 1;
-
- ptr = stktable_data_ptr(t, ts, STKTABLE_DT_HTTP_ERR_RATE);
- if (ptr) {
- HA_RWLOCK_RDLOCK(STK_SESS_LOCK, &ts->lock);
-
- smp->data.u.sint = read_freq_ctr_period(&stktable_data_cast(ptr, std_t_frqp),
- t->data_arg[STKTABLE_DT_HTTP_ERR_RATE].u);
+ struct stkctr stkctr;
- HA_RWLOCK_RDUNLOCK(STK_SESS_LOCK, &ts->lock);
- }
+ stkctr.table = arg_p[0].data.t;
+ stkctr_set_entry(&stkctr, smp_fetch_stksess(stkctr.table, smp, 0));
- stktable_release(t, ts);
- return !!ptr;
+ return smp_fetch_http_err_rate(&stkctr, smp, 1);
}
/* Casts sample <smp> to the type of the table specified in arg(0), and looks
* comparisons can be easily performed. If the inspected parameter is not stored
* in the table, <not found> is returned.
*/
+static int smp_fetch_http_fail_cnt(struct stkctr *stkctr, struct sample *smp, int decrefcnt);
static int sample_conv_table_http_fail_cnt(const struct arg *arg_p, struct sample *smp, void *private)
{
- struct stktable *t;
- struct stksess *ts;
- void *ptr;
+ struct stkctr stkctr;
- t = arg_p[0].data.t;
+ stkctr.table = arg_p[0].data.t;
+ stkctr_set_entry(&stkctr, smp_fetch_stksess(stkctr.table, smp, 0));
- ts = smp_fetch_stksess(t, smp, 0);
-
- smp->flags = SMP_F_VOL_TEST;
- smp->data.type = SMP_T_SINT;
- smp->data.u.sint = 0;
-
- if (!ts) /* key not present */
- return 1;
-
- ptr = stktable_data_ptr(t, ts, STKTABLE_DT_HTTP_FAIL_CNT);
- if (ptr) {
- HA_RWLOCK_RDLOCK(STK_SESS_LOCK, &ts->lock);
-
- smp->data.u.sint = stktable_data_cast(ptr, std_t_uint);
-
- HA_RWLOCK_RDUNLOCK(STK_SESS_LOCK, &ts->lock);
- }
-
- stktable_release(t, ts);
- return !!ptr;
+ return smp_fetch_http_fail_cnt(&stkctr, smp, 1);
}
/* Casts sample <smp> to the type of the table specified in arg(0), and looks
* be easily performed. If the inspected parameter is not stored in the table,
* <not found> is returned.
*/
+static int smp_fetch_http_fail_rate(struct stkctr *stkctr, struct sample *smp, int decrefcnt);
static int sample_conv_table_http_fail_rate(const struct arg *arg_p, struct sample *smp, void *private)
{
- struct stktable *t;
- struct stksess *ts;
- void *ptr;
-
- t = arg_p[0].data.t;
+ struct stkctr stkctr;
- ts = smp_fetch_stksess(t, smp, 0);
-
- smp->flags = SMP_F_VOL_TEST;
- smp->data.type = SMP_T_SINT;
- smp->data.u.sint = 0;
-
- if (!ts) /* key not present */
- return 1;
+ stkctr.table = arg_p[0].data.t;
+ stkctr_set_entry(&stkctr, smp_fetch_stksess(stkctr.table, smp, 0));
- ptr = stktable_data_ptr(t, ts, STKTABLE_DT_HTTP_FAIL_RATE);
- if (ptr) {
- HA_RWLOCK_RDLOCK(STK_SESS_LOCK, &ts->lock);
-
- smp->data.u.sint = read_freq_ctr_period(&stktable_data_cast(ptr, std_t_frqp),
- t->data_arg[STKTABLE_DT_HTTP_FAIL_RATE].u);
-
- HA_RWLOCK_RDUNLOCK(STK_SESS_LOCK, &ts->lock);
- }
-
- stktable_release(t, ts);
- return !!ptr;
+ return smp_fetch_http_fail_rate(&stkctr, smp, 1);
}
/* Casts sample <smp> to the type of the table specified in arg(0), and looks
* can be easily performed. If the inspected parameter is not stored in the
* table, <not found> is returned.
*/
+static int smp_fetch_http_req_cnt(struct stkctr *stkctr, struct sample *smp, int decrefcnt);
static int sample_conv_table_http_req_cnt(const struct arg *arg_p, struct sample *smp, void *private)
{
- struct stktable *t;
- struct stksess *ts;
- void *ptr;
-
- t = arg_p[0].data.t;
-
- ts = smp_fetch_stksess(t, smp, 0);
+ struct stkctr stkctr;
- smp->flags = SMP_F_VOL_TEST;
- smp->data.type = SMP_T_SINT;
- smp->data.u.sint = 0;
+ stkctr.table = arg_p[0].data.t;
+ stkctr_set_entry(&stkctr, smp_fetch_stksess(stkctr.table, smp, 0));
- if (!ts) /* key not present */
- return 1;
-
- ptr = stktable_data_ptr(t, ts, STKTABLE_DT_HTTP_REQ_CNT);
- if (ptr) {
- HA_RWLOCK_RDLOCK(STK_SESS_LOCK, &ts->lock);
-
- smp->data.u.sint = stktable_data_cast(ptr, std_t_uint);
-
- HA_RWLOCK_RDUNLOCK(STK_SESS_LOCK, &ts->lock);
- }
-
- stktable_release(t, ts);
- return !!ptr;
+ return smp_fetch_http_req_cnt(&stkctr, smp, 1);
}
/* Casts sample <smp> to the type of the table specified in arg(0), and looks
* performed. If the inspected parameter is not stored in the table, <not found>
* is returned.
*/
+static int smp_fetch_http_req_rate(struct stkctr *stkctr, struct sample *smp, int decrefcnt);
static int sample_conv_table_http_req_rate(const struct arg *arg_p, struct sample *smp, void *private)
{
- struct stktable *t;
- struct stksess *ts;
- void *ptr;
-
- t = arg_p[0].data.t;
-
- ts = smp_fetch_stksess(t, smp, 0);
-
- smp->flags = SMP_F_VOL_TEST;
- smp->data.type = SMP_T_SINT;
- smp->data.u.sint = 0;
+ struct stkctr stkctr;
- if (!ts) /* key not present */
- return 1;
+ stkctr.table = arg_p[0].data.t;
+ stkctr_set_entry(&stkctr, smp_fetch_stksess(stkctr.table, smp, 0));
- ptr = stktable_data_ptr(t, ts, STKTABLE_DT_HTTP_REQ_RATE);
- if (ptr) {
- HA_RWLOCK_RDLOCK(STK_SESS_LOCK, &ts->lock);
-
- smp->data.u.sint = read_freq_ctr_period(&stktable_data_cast(ptr, std_t_frqp),
- t->data_arg[STKTABLE_DT_HTTP_REQ_RATE].u);
-
- HA_RWLOCK_RDUNLOCK(STK_SESS_LOCK, &ts->lock);
- }
-
- stktable_release(t, ts);
- return !!ptr;
+ return smp_fetch_http_req_rate(&stkctr, smp, 1);
}
/* Casts sample <smp> to the type of the table specified in arg(0), and looks
* be easily performed. If the inspected parameter is not stored in the table,
* <not found> is returned.
*/
+static int smp_fetch_kbytes_in(struct stkctr *stkctr, struct sample *smp, int decrefcnt);
static int sample_conv_table_kbytes_in(const struct arg *arg_p, struct sample *smp, void *private)
{
- struct stktable *t;
- struct stksess *ts;
- void *ptr;
-
- t = arg_p[0].data.t;
-
- ts = smp_fetch_stksess(t, smp, 0);
+ struct stkctr stkctr;
- smp->flags = SMP_F_VOL_TEST;
- smp->data.type = SMP_T_SINT;
- smp->data.u.sint = 0;
-
- if (!ts) /* key not present */
- return 1;
-
- ptr = stktable_data_ptr(t, ts, STKTABLE_DT_BYTES_IN_CNT);
- if (ptr) {
- HA_RWLOCK_RDLOCK(STK_SESS_LOCK, &ts->lock);
-
- smp->data.u.sint = stktable_data_cast(ptr, std_t_ull) >> 10;
+ stkctr.table = arg_p[0].data.t;
+ stkctr_set_entry(&stkctr, smp_fetch_stksess(stkctr.table, smp, 0));
- HA_RWLOCK_RDUNLOCK(STK_SESS_LOCK, &ts->lock);
- }
-
- stktable_release(t, ts);
- return !!ptr;
+ return smp_fetch_kbytes_in(&stkctr, smp, 1);
}
/* Casts sample <smp> to the type of the table specified in arg(0), and looks
* be easily performed. If the inspected parameter is not stored in the table,
* <not found> is returned.
*/
+static int smp_fetch_kbytes_out(struct stkctr *stkctr, struct sample *smp, int decrefcnt);
static int sample_conv_table_kbytes_out(const struct arg *arg_p, struct sample *smp, void *private)
{
- struct stktable *t;
- struct stksess *ts;
- void *ptr;
+ struct stkctr stkctr;
- t = arg_p[0].data.t;
-
- ts = smp_fetch_stksess(t, smp, 0);
+ stkctr.table = arg_p[0].data.t;
+ stkctr_set_entry(&stkctr, smp_fetch_stksess(stkctr.table, smp, 0));
- smp->flags = SMP_F_VOL_TEST;
- smp->data.type = SMP_T_SINT;
- smp->data.u.sint = 0;
-
- if (!ts) /* key not present */
- return 1;
-
- ptr = stktable_data_ptr(t, ts, STKTABLE_DT_BYTES_OUT_CNT);
- if (ptr) {
- HA_RWLOCK_RDLOCK(STK_SESS_LOCK, &ts->lock);
-
- smp->data.u.sint = stktable_data_cast(ptr, std_t_ull) >> 10;
-
- HA_RWLOCK_RDUNLOCK(STK_SESS_LOCK, &ts->lock);
- }
-
- stktable_release(t, ts);
- return !!ptr;
+ return smp_fetch_kbytes_out(&stkctr, smp, 1);
}
/* Casts sample <smp> to the type of the table specified in arg(0), and looks
* can be easily performed. If the inspected parameter is not stored in the
* table, <not found> is returned.
*/
+static int smp_fetch_sess_cnt(struct stkctr *stkctr, struct sample *smp, int decrefcnt);
static int sample_conv_table_sess_cnt(const struct arg *arg_p, struct sample *smp, void *private)
{
- struct stktable *t;
- struct stksess *ts;
- void *ptr;
+ struct stkctr stkctr;
- t = arg_p[0].data.t;
+ stkctr.table = arg_p[0].data.t;
+ stkctr_set_entry(&stkctr, smp_fetch_stksess(stkctr.table, smp, 0));
- ts = smp_fetch_stksess(t, smp, 0);
-
- smp->flags = SMP_F_VOL_TEST;
- smp->data.type = SMP_T_SINT;
- smp->data.u.sint = 0;
-
- if (!ts) /* key not present */
- return 1;
-
- ptr = stktable_data_ptr(t, ts, STKTABLE_DT_SESS_CNT);
- if (ptr) {
- HA_RWLOCK_RDLOCK(STK_SESS_LOCK, &ts->lock);
-
- smp->data.u.sint = stktable_data_cast(ptr, std_t_uint);
-
- HA_RWLOCK_RDUNLOCK(STK_SESS_LOCK, &ts->lock);
- }
-
- stktable_release(t, ts);
- return !!ptr;
+ return smp_fetch_sess_cnt(&stkctr, smp, 1);
}
/* Casts sample <smp> to the type of the table specified in arg(0), and looks
* performed. If the inspected parameter is not stored in the table, <not found>
* is returned.
*/
+static int smp_fetch_sess_rate(struct stkctr *stkctr, struct sample *smp, int decrefcnt);
static int sample_conv_table_sess_rate(const struct arg *arg_p, struct sample *smp, void *private)
{
- struct stktable *t;
- struct stksess *ts;
- void *ptr;
-
- t = arg_p[0].data.t;
+ struct stkctr stkctr;
- ts = smp_fetch_stksess(t, smp, 0);
-
- smp->flags = SMP_F_VOL_TEST;
- smp->data.type = SMP_T_SINT;
- smp->data.u.sint = 0;
-
- if (!ts) /* key not present */
- return 1;
+ stkctr.table = arg_p[0].data.t;
+ stkctr_set_entry(&stkctr, smp_fetch_stksess(stkctr.table, smp, 0));
- ptr = stktable_data_ptr(t, ts, STKTABLE_DT_SESS_RATE);
- if (ptr) {
- HA_RWLOCK_RDLOCK(STK_SESS_LOCK, &ts->lock);
-
- smp->data.u.sint = read_freq_ctr_period(&stktable_data_cast(ptr, std_t_frqp),
- t->data_arg[STKTABLE_DT_SESS_RATE].u);
-
- HA_RWLOCK_RDUNLOCK(STK_SESS_LOCK, &ts->lock);
- }
-
- stktable_release(t, ts);
- return !!ptr;
+ return smp_fetch_sess_rate(&stkctr, smp, 1);
}
/* Casts sample <smp> to the type of the table specified in arg(0), and looks