MINOR: mux-h2: extract the code to send preface+settings into its own function

The code that deals with sending preface + settings and changing the
state currently is in h2_process_mux(), but we'll want to do it as
well from h2_snd_buf(), so let's move it to a dedicate function first.
At this point there is no functional change.
This commit is contained in:
Willy Tarreau 2025-10-29 17:28:57 +01:00
parent b0e8edaef2
commit d5aa3e19cc

View File

@ -4643,6 +4643,23 @@ static inline void h2_remove_from_list(struct h2s *h2s)
}
}
/* Sends the preface and the settings on a backend connection, and updates the
* connection's state to H2_CS_SETTINGS1. May only be called when the state is
* below H2_CS_SETTINGS1. It returns < 0 on error with the error set, otherwise
* >= 0.
*/
static int h2c_bck_send_preface_and_settings(struct h2c *h2c)
{
if (unlikely(h2c_bck_send_preface(h2c) <= 0)) {
/* RFC7540#3.5: a GOAWAY frame MAY be omitted */
if (h2c->st0 == H2_CS_ERROR)
h2c->st0 = H2_CS_ERROR2;
return -1;
}
h2c->st0 = H2_CS_SETTINGS1;
return 0;
}
/* process Tx frames from streams to be multiplexed. Returns > 0 if it reached
* the end.
*/
@ -4652,13 +4669,8 @@ static int h2_process_mux(struct h2c *h2c)
if (unlikely(h2c->st0 < (h2c->flags & H2_CF_SETTINGS_NEEDED ? H2_CS_FRAME_H : H2_CS_SETTINGS1))) {
if (unlikely(h2c->st0 == H2_CS_PREFACE && (h2c->flags & H2_CF_IS_BACK))) {
if (unlikely(h2c_bck_send_preface(h2c) <= 0)) {
/* RFC7540#3.5: a GOAWAY frame MAY be omitted */
if (h2c->st0 == H2_CS_ERROR)
h2c->st0 = H2_CS_ERROR2;
if (h2c_bck_send_preface_and_settings(h2c) < 0)
goto fail;
}
h2c->st0 = H2_CS_SETTINGS1;
}
/* need to wait for the other side */
if (h2c->st0 < (h2c->flags & H2_CF_SETTINGS_NEEDED ? H2_CS_FRAME_H : H2_CS_SETTINGS1))