mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-07 23:56:57 +02:00
MINOR: h2: provide and use h2s_detach() and h2s_free()
These ones save us from open-coding the cleanup functions on each and every error path. The code was updated to use them with no functional change.
This commit is contained in:
parent
00dd07895a
commit
0a10de6066
38
src/mux_h2.c
38
src/mux_h2.c
@ -642,6 +642,19 @@ static inline void h2s_close(struct h2s *h2s)
|
|||||||
h2s->st = H2_SS_CLOSED;
|
h2s->st = H2_SS_CLOSED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* detaches an H2 stream from its H2C. */
|
||||||
|
static void h2s_detach(struct h2s *h2s)
|
||||||
|
{
|
||||||
|
h2s_close(h2s);
|
||||||
|
eb32_delete(&h2s->by_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* releases an H2 stream back to the pool, and detaches it from the h2c. */
|
||||||
|
static void h2s_free(struct h2s *h2s)
|
||||||
|
{
|
||||||
|
pool_free(pool_head_h2s, h2s);
|
||||||
|
}
|
||||||
|
|
||||||
/* creates a new stream <id> on the h2c connection and returns it, or NULL in
|
/* creates a new stream <id> on the h2c connection and returns it, or NULL in
|
||||||
* case of memory allocation error.
|
* case of memory allocation error.
|
||||||
*/
|
*/
|
||||||
@ -686,9 +699,8 @@ static struct h2s *h2c_stream_new(struct h2c *h2c, int id)
|
|||||||
out_free_cs:
|
out_free_cs:
|
||||||
cs_free(cs);
|
cs_free(cs);
|
||||||
out_close:
|
out_close:
|
||||||
h2c->nb_streams--;
|
h2s_detach(h2s);
|
||||||
eb32_delete(&h2s->by_id);
|
h2s_free(h2s);
|
||||||
pool_free(pool_head_h2s, h2s);
|
|
||||||
h2s = NULL;
|
h2s = NULL;
|
||||||
out:
|
out:
|
||||||
return h2s;
|
return h2s;
|
||||||
@ -1048,9 +1060,8 @@ static void h2_wake_some_streams(struct h2c *h2c, int last, uint32_t flags)
|
|||||||
|
|
||||||
if (!h2s->cs) {
|
if (!h2s->cs) {
|
||||||
/* this stream was already orphaned */
|
/* this stream was already orphaned */
|
||||||
h2s_close(h2s);
|
h2s_detach(h2s);
|
||||||
eb32_delete(&h2s->by_id);
|
h2s_free(h2s);
|
||||||
pool_free(pool_head_h2s, h2s);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2081,9 +2092,8 @@ static int h2_process_mux(struct h2c *h2c)
|
|||||||
h2s->cs->flags &= ~CS_FL_DATA_WR_ENA;
|
h2s->cs->flags &= ~CS_FL_DATA_WR_ENA;
|
||||||
else {
|
else {
|
||||||
/* just sent the last frame for this orphaned stream */
|
/* just sent the last frame for this orphaned stream */
|
||||||
h2s_close(h2s);
|
h2s_detach(h2s);
|
||||||
eb32_delete(&h2s->by_id);
|
h2s_free(h2s);
|
||||||
pool_free(pool_head_h2s, h2s);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2124,9 +2134,8 @@ static int h2_process_mux(struct h2c *h2c)
|
|||||||
h2s->cs->flags &= ~CS_FL_DATA_WR_ENA;
|
h2s->cs->flags &= ~CS_FL_DATA_WR_ENA;
|
||||||
else {
|
else {
|
||||||
/* just sent the last frame for this orphaned stream */
|
/* just sent the last frame for this orphaned stream */
|
||||||
h2s_close(h2s);
|
h2s_detach(h2s);
|
||||||
eb32_delete(&h2s->by_id);
|
h2s_free(h2s);
|
||||||
pool_free(pool_head_h2s, h2s);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2494,8 +2503,7 @@ static void h2_detach(struct conn_stream *cs)
|
|||||||
|
|
||||||
if (h2s->by_id.node.leaf_p) {
|
if (h2s->by_id.node.leaf_p) {
|
||||||
/* h2s still attached to the h2c */
|
/* h2s still attached to the h2c */
|
||||||
h2s_close(h2s);
|
h2s_detach(h2s);
|
||||||
eb32_delete(&h2s->by_id);
|
|
||||||
|
|
||||||
/* We don't want to close right now unless we're removing the
|
/* We don't want to close right now unless we're removing the
|
||||||
* last stream, and either the connection is in error, or it
|
* last stream, and either the connection is in error, or it
|
||||||
@ -2520,7 +2528,7 @@ static void h2_detach(struct conn_stream *cs)
|
|||||||
h2c->task->expire = TICK_ETERNITY;
|
h2c->task->expire = TICK_ETERNITY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pool_free(pool_head_h2s, h2s);
|
h2s_free(h2s);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void h2_shutr(struct conn_stream *cs, enum cs_shr_mode mode)
|
static void h2_shutr(struct conn_stream *cs, enum cs_shr_mode mode)
|
||||||
|
Loading…
Reference in New Issue
Block a user