BUG/MINOR: 51d: Fix bug when HTX is enabled
When HTX is enabled, the sample flags were set too early. When matching for multiple HTTP headers, the sample is fetched more than once, meaning that the flags would need to be set again. Instead, the flags are now set last (just before the outermost function returns). This could be further improved by passing around the message without calling prefetch again. This patch must be backported as far as 1.9. it should fix bug #450.
This commit is contained in:
parent
fcac33d0c1
commit
6bf0672711
29
src/51d.c
29
src/51d.c
|
@ -395,6 +395,21 @@ static void _51d_process_match(const struct arg *args, struct sample *smp, fifty
|
||||||
smp->data.u.str.data = temp->data;
|
smp->data.u.str.data = temp->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Sets the sample data as a constant string. This ensures that the
|
||||||
|
* string will be processed correctly.
|
||||||
|
*/
|
||||||
|
static void _51d_set_smp(struct sample *smp)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Data type has to be set to ensure the string output is processed
|
||||||
|
* correctly.
|
||||||
|
*/
|
||||||
|
smp->data.type = SMP_T_STR;
|
||||||
|
|
||||||
|
/* Flags the sample to show it uses constant memory. */
|
||||||
|
smp->flags |= SMP_F_CONST;
|
||||||
|
}
|
||||||
|
|
||||||
static int _51d_fetch(const struct arg *args, struct sample *smp, const char *kw, void *private)
|
static int _51d_fetch(const struct arg *args, struct sample *smp, const char *kw, void *private)
|
||||||
{
|
{
|
||||||
#ifdef FIFTYONEDEGREES_H_PATTERN_INCLUDED
|
#ifdef FIFTYONEDEGREES_H_PATTERN_INCLUDED
|
||||||
|
@ -413,14 +428,6 @@ static int _51d_fetch(const struct arg *args, struct sample *smp, const char *kw
|
||||||
if (!htx)
|
if (!htx)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/*
|
|
||||||
* Data type has to be reset to ensure the string output is processed
|
|
||||||
* correctly.
|
|
||||||
*/
|
|
||||||
smp->data.type = SMP_T_STR;
|
|
||||||
|
|
||||||
/* Flags the sample to show it uses constant memory*/
|
|
||||||
smp->flags |= SMP_F_CONST;
|
|
||||||
|
|
||||||
#ifdef FIFTYONEDEGREES_H_PATTERN_INCLUDED
|
#ifdef FIFTYONEDEGREES_H_PATTERN_INCLUDED
|
||||||
|
|
||||||
|
@ -448,6 +455,8 @@ static int _51d_fetch(const struct arg *args, struct sample *smp, const char *kw
|
||||||
fiftyoneDegreesWorksetPoolRelease(global_51degrees.pool, ws);
|
fiftyoneDegreesWorksetPoolRelease(global_51degrees.pool, ws);
|
||||||
_51d_retrieve_cache_entry(smp, lru);
|
_51d_retrieve_cache_entry(smp, lru);
|
||||||
HA_SPIN_UNLOCK(OTHER_LOCK, &_51d_lru_lock);
|
HA_SPIN_UNLOCK(OTHER_LOCK, &_51d_lru_lock);
|
||||||
|
|
||||||
|
_51d_set_smp(smp);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
HA_SPIN_UNLOCK(OTHER_LOCK, &_51d_lru_lock);
|
HA_SPIN_UNLOCK(OTHER_LOCK, &_51d_lru_lock);
|
||||||
|
@ -485,6 +494,7 @@ static int _51d_fetch(const struct arg *args, struct sample *smp, const char *kw
|
||||||
_51d_insert_cache_entry(smp, lru, (void*)args);
|
_51d_insert_cache_entry(smp, lru, (void*)args);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
_51d_set_smp(smp);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -497,8 +507,6 @@ static int _51d_conv(const struct arg *args, struct sample *smp, void *private)
|
||||||
#ifdef FIFTYONEDEGREES_H_TRIE_INCLUDED
|
#ifdef FIFTYONEDEGREES_H_TRIE_INCLUDED
|
||||||
fiftyoneDegreesDeviceOffsets *offsets; /* Offsets for detection */
|
fiftyoneDegreesDeviceOffsets *offsets; /* Offsets for detection */
|
||||||
#endif
|
#endif
|
||||||
/* Flags the sample to show it uses constant memory*/
|
|
||||||
smp->flags |= SMP_F_CONST;
|
|
||||||
|
|
||||||
#ifdef FIFTYONEDEGREES_H_PATTERN_INCLUDED
|
#ifdef FIFTYONEDEGREES_H_PATTERN_INCLUDED
|
||||||
|
|
||||||
|
@ -560,6 +568,7 @@ static int _51d_conv(const struct arg *args, struct sample *smp, void *private)
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
_51d_set_smp(smp);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue