2121#include "connection.h"
2222#include "dns_server.h"
2323#include "server_tls.h"
24+ #include "smartdns/dns_conf.h"
2425#include "smartdns/http2.h"
2526#include "smartdns/tlog.h"
2627#include "smartdns/util.h"
@@ -216,10 +217,6 @@ int _dns_server_process_http2(struct dns_server_conn_tls_client *tls_client, str
216217 tlog (TLOG_ERROR , "init http2 context failed." );
217218 return -1 ;
218219 }
219- if (tls_client -> http2_ctx != NULL ) {
220- http2_ctx_close (tls_client -> http2_ctx );
221- }
222- tls_client -> http2_ctx = ctx ;
223220
224221 /* Perform initial handshake */
225222 ret = http2_ctx_handshake (ctx );
@@ -230,8 +227,11 @@ int _dns_server_process_http2(struct dns_server_conn_tls_client *tls_client, str
230227 log_level = TLOG_DEBUG ; /* Less noisy for clients that disconnect early or misbehave */
231228 }
232229 tlog (log_level , "http2 handshake failed, ret=%d (%s), alpn=%s." , ret , err_msg , tls_client -> alpn_selected );
230+ http2_ctx_close (ctx );
233231 return -1 ;
234232 }
233+
234+ tls_client -> http2_ctx = ctx ;
235235 }
236236
237237 /* Handle EPOLLOUT - flush pending writes */
@@ -252,7 +252,7 @@ int _dns_server_process_http2(struct dns_server_conn_tls_client *tls_client, str
252252 struct http2_poll_item poll_items [10 ];
253253 int poll_count = 0 ;
254254 int loop_count = 0 ;
255- const int MAX_LOOP_COUNT = 128 ;
255+ const int MAX_LOOP_COUNT = 512 ;
256256
257257 /* Ensure handshake is complete */
258258 ret = http2_ctx_handshake (ctx );
0 commit comments