summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValentin Bartenev <vbart@nginx.com>2015-10-26 17:46:16 +0300
committerValentin Bartenev <vbart@nginx.com>2015-10-26 17:46:16 +0300
commitd418b92cdcc869c39eff75d90e62182352d6978e (patch)
treea250b05fcb2fe61dcdea3b45a3f5cd9ee41e3483
parent3565680d94501330d0d6d1d539eb7538a681b425 (diff)
HTTP/2: improved the ngx_http_v2_integer_octets(v) macro.
Previously, it didn't work well for 0, 127, and 128, returning less than needed.
-rw-r--r--src/http/v2/ngx_http_v2_filter_module.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/http/v2/ngx_http_v2_filter_module.c b/src/http/v2/ngx_http_v2_filter_module.c
index 2d1ced6a..a866cdef 100644
--- a/src/http/v2/ngx_http_v2_filter_module.c
+++ b/src/http/v2/ngx_http_v2_filter_module.c
@@ -12,7 +12,12 @@
#include <ngx_http_v2_module.h>
-#define ngx_http_v2_integer_octets(v) (((v) + 127) / 128)
+/*
+ * This returns precise number of octets for values in range 0..253
+ * and estimate number for the rest, but not smaller than required.
+ */
+
+#define ngx_http_v2_integer_octets(v) (1 + (v) / 127)
#define ngx_http_v2_literal_size(h) \
(ngx_http_v2_integer_octets(sizeof(h) - 1) + sizeof(h) - 1)