mirror of
http://git.haproxy.org/git/haproxy.git
synced 2026-02-10 14:12:41 +02:00
MINOR: stream-int: use bit fields to match multiple stream-int states at once
At some places we do check for ranges of stream-int states but those are confusing as states ordering is not well known (e.g. it's not obvious that CER is between CON and EST). Let's create a bit field from states so that we can match multiple states at once instead. The new enum si_state_bit contains SI_SB_* which are state bits instead of state values. The function si_state_in() indicates if the state in argument is one of those represented by the bit mask in second argument.
This commit is contained in:
@@ -138,6 +138,20 @@ static inline void si_set_state(struct stream_interface *si, int state)
|
||||
si->state = si->prev_state = state;
|
||||
}
|
||||
|
||||
/* returns a bit for a stream-int state, to match against SI_SB_* */
|
||||
static inline enum si_state_bit si_state_bit(enum si_state state)
|
||||
{
|
||||
BUG_ON(state < SI_ST_INI || state > SI_ST_CLO);
|
||||
return 1U << state;
|
||||
}
|
||||
|
||||
/* returns true if <state> matches one of the SI_SB_* bits in <mask> */
|
||||
static inline int si_state_in(enum si_state state, enum si_state_bit mask)
|
||||
{
|
||||
BUG_ON(mask & ~SI_SB_ALL);
|
||||
return !!(si_state_bit(state) & mask);
|
||||
}
|
||||
|
||||
/* only detaches the endpoint from the SI, which means that it's set to
|
||||
* NULL and that ->ops is mapped to si_embedded_ops. The previous endpoint
|
||||
* is returned.
|
||||
|
||||
Reference in New Issue
Block a user