mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-24 07:11:20 +02:00
BUG/MINOR: connection: "connection:close" header added despite 'close-spread-time'
Despite what the 'close-spread-time' option should do, the 'connection:close' header was always added to HTTP responses during soft-stops even with a soft-stop window defined. This patch adds the proper random based closing to HTTP connections during a soft-stop (based on the time left in the soft close window). It should be backported to 2.5 once 'MEDIUM: global: Add a "close-spread-time" option to spread soft-stop on time window' is backported as well.
This commit is contained in:
parent
acef5e27b0
commit
b4f5fac886
25
src/mux_h1.c
25
src/mux_h1.c
@ -1197,10 +1197,29 @@ static void h1_set_cli_conn_mode(struct h1s *h1s, struct h1m *h1m)
|
||||
}
|
||||
}
|
||||
|
||||
/* If KAL, check if the frontend is stopping. If yes, switch in CLO mode */
|
||||
/* If KAL, check if the frontend is stopping. If yes, switch in CLO mode
|
||||
* unless a 'close-spread-time' option is set.
|
||||
*/
|
||||
if (h1s->flags & H1S_F_WANT_KAL && (fe->flags & (PR_FL_DISABLED|PR_FL_STOPPED))) {
|
||||
h1s->flags = (h1s->flags & ~H1S_F_WANT_MSK) | H1S_F_WANT_CLO;
|
||||
TRACE_STATE("stopping, set close mode", H1_EV_RX_DATA|H1_EV_RX_HDRS|H1_EV_TX_DATA|H1_EV_TX_HDRS, h1s->h1c->conn, h1s);
|
||||
int want_clo = 1;
|
||||
/* If a close-spread-time option is set, we want to avoid
|
||||
* closing all the active HTTP connections at once so we add a
|
||||
* random factor that will spread the closing.
|
||||
*/
|
||||
if (tick_isset(global.close_spread_end)) {
|
||||
int remaining_window = tick_remain(now_ms, global.close_spread_end);
|
||||
if (remaining_window) {
|
||||
/* This should increase the closing rate the further along
|
||||
* the window we are.
|
||||
*/
|
||||
want_clo = (remaining_window <= statistical_prng_range(global.close_spread_time));
|
||||
}
|
||||
}
|
||||
|
||||
if (want_clo) {
|
||||
h1s->flags = (h1s->flags & ~H1S_F_WANT_MSK) | H1S_F_WANT_CLO;
|
||||
TRACE_STATE("stopping, set close mode", H1_EV_RX_DATA|H1_EV_RX_HDRS|H1_EV_TX_DATA|H1_EV_TX_HDRS, h1s->h1c->conn, h1s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user