Hi Tim,

On Tue, Jun 26, 2018 at 03:57:29PM +0200, Tim Duesterhus wrote:
> diff --git a/src/stick_table.c b/src/stick_table.c
> index 42946545..8e16830d 100644
> --- a/src/stick_table.c
> +++ b/src/stick_table.c
> @@ -1596,8 +1596,10 @@ static int sample_conv_table_trackers(const struct arg 
> *arg_p, struct sample *sm
>       smp->data.type = SMP_T_SINT;
>       smp->data.u.sint = 0;
>  
> -     if (ts)
> -             smp->data.u.sint = ts->ref_cnt;
> +     if (!ts)
> +             return 1;
> +
> +     smp->data.u.sint = ts->ref_cnt;
>  
>       stktable_release(t, ts);
>       return 1;

Well, I don't understand, this does exactly the same as the current patch
(except that your version is not thread safe), given that right now it
does this :


/* Just decrease the ref_cnt of the current session */
void stktable_release(struct stktable *t, struct stksess *ts)
{
        HA_SPIN_LOCK(STK_TABLE_LOCK, &t->lock);
        ts->ref_cnt--;
        HA_SPIN_UNLOCK(STK_TABLE_LOCK, &t->lock);
}

...
        smp->data.type = SMP_T_BOOL;
        smp->data.u.sint = !!ts;
        smp->flags = SMP_F_VOL_TEST;
        if (ts)
                stktable_release(t, ts);
...

So that's in fact :

        smp->data.type = SMP_T_BOOL;
        smp->data.u.sint = !!ts;
        smp->flags = SMP_F_VOL_TEST;
        if (ts) {
                HA_SPIN_LOCK(STK_TABLE_LOCK, &t->lock);
                ts->ref_cnt--;
                HA_SPIN_UNLOCK(STK_TABLE_LOCK, &t->lock);
        }

Thus, if ts is NULL, we do return immediately with value zero, and
if it's not NULL, we properly decrement the refcount.

Given that your patch is applied on top of the unfixed version, I
suspect that you did a manipulation error and that you tested only
this unfixed version instead.

Could you please double-check ?

Thanks,
Willy

Reply via email to