Skip to content

Commit

Permalink
- For #1103: Fix to drop mesh state reference for the http2 stream
Browse files Browse the repository at this point in the history
  associated with the reply, not the currently active stream. And
  it does not remove it twice on a mesh_send_reply call. The reply
  h2_stream is NULL when not in use, for more initialisation.
  • Loading branch information
wcawijngaards committed Jul 16, 2024
1 parent 8947c2c commit 8fca3e7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
6 changes: 6 additions & 0 deletions doc/Changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
16 July 2024: Wouter
- For #1103: Fix to drop mesh state reference for the http2 stream
associated with the reply, not the currently active stream. And
it does not remove it twice on a mesh_send_reply call. The reply
h2_stream is NULL when not in use, for more initialisation.

15 July 2024: Wouter
- For #1103: fix to also drop mesh state reference when the discard
limit is reached, when there is an error making a new recursion
Expand Down
23 changes: 8 additions & 15 deletions services/mesh.c
Original file line number Diff line number Diff line change
Expand Up @@ -977,8 +977,7 @@ mesh_state_cleanup(struct mesh_state* mstate)
infra_wait_limit_dec(mesh->env->infra_cache,
&rep->query_reply, mesh->env->cfg);
if(rep->query_reply.c->use_h2)
http2_stream_remove_mesh_state(
rep->query_reply.c->h2_stream);
http2_stream_remove_mesh_state(rep->h2_stream);
comm_point_drop_reply(&rep->query_reply);
log_assert(mesh->num_reply_addrs > 0);
mesh->num_reply_addrs--;
Expand Down Expand Up @@ -1536,8 +1535,7 @@ void mesh_query_done(struct mesh_state* mstate)
&r->query_reply, mstate->s.env->cfg);
mstate->reply_list = NULL;
if(r->query_reply.c->use_h2)
http2_stream_remove_mesh_state(
r->query_reply.c->h2_stream);
http2_stream_remove_mesh_state(r->h2_stream);
comm_point_drop_reply(&r->query_reply);
mstate->reply_list = reply_list;
mstate->s.env->mesh->stats_dropped++;
Expand Down Expand Up @@ -1571,8 +1569,7 @@ void mesh_query_done(struct mesh_state* mstate)
&r->query_reply, mstate->s.env->cfg);
mstate->reply_list = NULL;
if(r->query_reply.c->use_h2) {
http2_stream_remove_mesh_state(
r->query_reply.c->h2_stream);
http2_stream_remove_mesh_state(r->h2_stream);
}
comm_point_drop_reply(&r->query_reply);
mstate->reply_list = reply_list;
Expand All @@ -1588,10 +1585,8 @@ void mesh_query_done(struct mesh_state* mstate)
tcp_req_info_remove_mesh_state(r->query_reply.c->tcp_req_info, mstate);
r_buffer = NULL;
}
if(r->query_reply.c->use_h2) {
http2_stream_remove_mesh_state(
r->query_reply.c->h2_stream);
}
/* mesh_send_reply removed mesh state from
* http2_stream. */
prev = r;
prev_buffer = r_buffer;
}
Expand Down Expand Up @@ -1744,6 +1739,7 @@ int mesh_state_add_reply(struct mesh_state* s, struct edns_data* edns,
return 0;
if(rep->c->use_h2)
r->h2_stream = rep->c->h2_stream;
else r->h2_stream = NULL;

/* Data related to local alias stored in 'qinfo' (if any) is ephemeral
* and can be different for different original queries (even if the
Expand Down Expand Up @@ -2268,8 +2264,7 @@ mesh_serve_expired_callback(void* arg)
&r->query_reply, mstate->s.env->cfg);
mstate->reply_list = NULL;
if(r->query_reply.c->use_h2)
http2_stream_remove_mesh_state(
r->query_reply.c->h2_stream);
http2_stream_remove_mesh_state(r->h2_stream);
comm_point_drop_reply(&r->query_reply);
mstate->reply_list = reply_list;
mstate->s.env->mesh->stats_dropped++;
Expand Down Expand Up @@ -2303,9 +2298,7 @@ mesh_serve_expired_callback(void* arg)
r, r_buffer, prev, prev_buffer);
if(r->query_reply.c->tcp_req_info)
tcp_req_info_remove_mesh_state(r->query_reply.c->tcp_req_info, mstate);
if(r->query_reply.c->use_h2)
http2_stream_remove_mesh_state(
r->query_reply.c->h2_stream);
/* mesh_send_reply removed mesh state from http2_stream. */
infra_wait_limit_dec(mstate->s.env->infra_cache,
&r->query_reply, mstate->s.env->cfg);
prev = r;
Expand Down

0 comments on commit 8fca3e7

Please sign in to comment.