Welcome! Log In Create A New Profile

Advanced

[PATCH] HTTP/2: premalloc http2 recv_buffer in init_conf

Kasei Wang
September 07, 2020 08:08AM
# HG changeset patch
# User Kasei Wang <kasei@kasei.im>
# Date 1599480224 -28800
# Mon Sep 07 20:03:44 2020 +0800
# Node ID 1532a8fca7b24c3c3aa5cddd3362402d15f57a4f
# Parent 87d2ea860f380dc8418c97c0163412f53c2d008e
HTTP/2: premalloc http2 recv_buffer in init_conf

There is no need to check if h2mcf->recv_buffer malloced every time.

diff -r 87d2ea860f38 -r 1532a8fca7b2 src/http/v2/ngx_http_v2.c
--- a/src/http/v2/ngx_http_v2.c Mon Sep 10 18:57:39 2018 +0300
+++ b/src/http/v2/ngx_http_v2.c Mon Sep 07 20:03:44 2020 +0800
@@ -233,7 +233,6 @@
ngx_pool_cleanup_t *cln;
ngx_http_connection_t *hc;
ngx_http_v2_srv_conf_t *h2scf;
- ngx_http_v2_main_conf_t *h2mcf;
ngx_http_v2_connection_t *h2c;

c = rev->data;
@@ -243,17 +242,6 @@

c->log->action = "processing HTTP/2 connection";

- h2mcf = ngx_http_get_module_main_conf(hc->conf_ctx, ngx_http_v2_module);
-
- if (h2mcf->recv_buffer == NULL) {
- h2mcf->recv_buffer = ngx_palloc(ngx_cycle->pool,
- h2mcf->recv_buffer_size);
- if (h2mcf->recv_buffer == NULL) {
- ngx_http_close_connection(c);
- return;
- }
- }
-
h2c = ngx_pcalloc(c->pool, sizeof(ngx_http_v2_connection_t));
if (h2c == NULL) {
ngx_http_close_connection(c);
diff -r 87d2ea860f38 -r 1532a8fca7b2 src/http/v2/ngx_http_v2_module.c
--- a/src/http/v2/ngx_http_v2_module.c Mon Sep 10 18:57:39 2018 +0300
+++ b/src/http/v2/ngx_http_v2_module.c Mon Sep 07 20:03:44 2020 +0800
@@ -334,6 +334,10 @@
ngx_http_v2_main_conf_t *h2mcf = conf;

ngx_conf_init_size_value(h2mcf->recv_buffer_size, 256 * 1024);
+ h2mcf->recv_buffer = ngx_pcalloc(cf->pool, h2mcf->recv_buffer_size);
+ if (h2mcf->recv_buffer == NULL) {
+ return NGX_CONF_ERROR;
+ }

return NGX_CONF_OK;
}
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[PATCH] HTTP/2: premalloc http2 recv_buffer in init_conf

Kasei Wang 67 September 07, 2020 08:08AM

Re: [PATCH] HTTP/2: premalloc http2 recv_buffer in init_conf

Maxim Dounin 21 September 07, 2020 09:26AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 52
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready