From 0784ad7a1185c3f2852e6d44308c06409e05f0d5 Mon Sep 17 00:00:00 2001 From: daiyunwei Date: Tue, 3 Aug 2021 11:40:30 +0800 Subject: [PATCH] #420 clear the c->buffer in the comm_point_send_reply does resolve the "can't fit qbuffer in c->buffer" issue, but it breaks the mesh reply list function that need to reuse the answer. because the c->buffer is cleared in the comm_point_send_reply, it cannot be resued again. it means that it is not inappropriate to clear c->buffer in the comm_point_send_reply. After some investigation, i found it is appropriate to clear c->buffer before use in the http2_query_read_done. --- services/listen_dnsport.c | 4 ++++ util/netevent.c | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/services/listen_dnsport.c b/services/listen_dnsport.c index 52b0a2ee9..b43def567 100644 --- a/services/listen_dnsport.c +++ b/services/listen_dnsport.c @@ -2477,6 +2477,10 @@ static int http2_query_read_done(struct http2_session* h2_session, "buffer already assigned to stream"); return -1; } + + /* the c->buffer might be used by mesh_send_reply and no be cleard + * need to be cleared before use */ + sldns_buffer_clear(h2_session->c->buffer); if(sldns_buffer_remaining(h2_session->c->buffer) < sldns_buffer_remaining(h2_stream->qbuffer)) { /* qbuffer will be free'd in frame close cb */ diff --git a/util/netevent.c b/util/netevent.c index d1316c5b4..a2defcb5f 100644 --- a/util/netevent.c +++ b/util/netevent.c @@ -4063,7 +4063,6 @@ comm_point_send_reply(struct comm_reply *repinfo) } repinfo->c->h2_stream = NULL; repinfo->c->tcp_is_reading = 0; - sldns_buffer_clear(repinfo->c->buffer); comm_point_stop_listening(repinfo->c); comm_point_start_listening(repinfo->c, -1, adjusted_tcp_timeout(repinfo->c)); -- 2.47.2