summaryrefslogtreecommitdiffhomepage
path: root/src/http/v3/ngx_http_v3_table.c
diff options
context:
space:
mode:
authorRoman Arutyunyan <arut@nginx.com>2022-01-27 12:20:47 +0300
committerRoman Arutyunyan <arut@nginx.com>2022-01-27 12:20:47 +0300
commitc1b172f1d67f806c84dc088ddc57ed76514e85dd (patch)
treecb917e952413aa61e8641ae88d39ba5358e697eb /src/http/v3/ngx_http_v3_table.c
parentacb585518d868a5051c1caa85add006d975751f5 (diff)
downloadnginx-c1b172f1d67f806c84dc088ddc57ed76514e85dd.tar.gz
nginx-c1b172f1d67f806c84dc088ddc57ed76514e85dd.tar.bz2
HTTP/3: delayed Insert Count Increment instruction.
Sending the instruction is delayed until the end of the current event cycle. Delaying the instruction is allowed by quic-qpack-21, section 2.2.2.3. The goal is to reduce the amount of data sent back to client by accumulating several inserts in one instruction and sometimes not sending the instruction at all, if Section Acknowledgement was sent just before it.
Diffstat (limited to 'src/http/v3/ngx_http_v3_table.c')
-rw-r--r--src/http/v3/ngx_http_v3_table.c49
1 files changed, 45 insertions, 4 deletions
diff --git a/src/http/v3/ngx_http_v3_table.c b/src/http/v3/ngx_http_v3_table.c
index c6d543ac4..22dc37901 100644
--- a/src/http/v3/ngx_http_v3_table.c
+++ b/src/http/v3/ngx_http_v3_table.c
@@ -232,11 +232,9 @@ ngx_http_v3_insert(ngx_connection_t *c, ngx_str_t *name, ngx_str_t *value)
dt->elts[dt->nelts++] = field;
dt->size += size;
- /* TODO increment can be sent less often */
+ dt->insert_count++;
- if (ngx_http_v3_send_inc_insert_count(c, 1) != NGX_OK) {
- return NGX_ERROR;
- }
+ ngx_post_event(&dt->send_insert_count, &ngx_posted_events);
if (ngx_http_v3_new_entry(c) != NGX_OK) {
return NGX_ERROR;
@@ -246,6 +244,34 @@ ngx_http_v3_insert(ngx_connection_t *c, ngx_str_t *name, ngx_str_t *value)
}
+void
+ngx_http_v3_inc_insert_count_handler(ngx_event_t *ev)
+{
+ ngx_connection_t *c;
+ ngx_http_v3_session_t *h3c;
+ ngx_http_v3_dynamic_table_t *dt;
+
+ c = ev->data;
+
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0,
+ "http3 inc insert count handler");
+
+ h3c = ngx_http_v3_get_session(c);
+ dt = &h3c->table;
+
+ if (dt->insert_count > dt->ack_insert_count) {
+ if (ngx_http_v3_send_inc_insert_count(c,
+ dt->insert_count - dt->ack_insert_count)
+ != NGX_OK)
+ {
+ return;
+ }
+
+ dt->ack_insert_count = dt->insert_count;
+ }
+}
+
+
ngx_int_t
ngx_http_v3_set_capacity(ngx_connection_t *c, ngx_uint_t capacity)
{
@@ -607,6 +633,21 @@ ngx_http_v3_check_insert_count(ngx_connection_t *c, ngx_uint_t insert_count)
}
+void
+ngx_http_v3_ack_insert_count(ngx_connection_t *c, uint64_t insert_count)
+{
+ ngx_http_v3_session_t *h3c;
+ ngx_http_v3_dynamic_table_t *dt;
+
+ h3c = ngx_http_v3_get_session(c);
+ dt = &h3c->table;
+
+ if (dt->ack_insert_count < insert_count) {
+ dt->ack_insert_count = insert_count;
+ }
+}
+
+
static void
ngx_http_v3_unblock(void *data)
{