]> git.kaiwu.me - nginx.git/commitdiff
HTTP/3: moved session initialization to a separate file.
authorRoman Arutyunyan <arut@nginx.com>
Wed, 5 May 2021 12:15:48 +0000 (15:15 +0300)
committerRoman Arutyunyan <arut@nginx.com>
Wed, 5 May 2021 12:15:48 +0000 (15:15 +0300)
Previously it was in ngx_http_v3_streams.c, but it's unrelated to streams.

auto/modules
src/http/v3/ngx_http_v3.c [new file with mode: 0644]
src/http/v3/ngx_http_v3_streams.c
src/http/v3/ngx_http_v3_streams.h

index 464111263e0b9b793acae137810ee194b9879844..d454466af4be44782864ad899145ac1193d477e6 100644 (file)
@@ -431,7 +431,8 @@ if [ $HTTP = YES ]; then
                          src/http/v3/ngx_http_v3_parse.h \
                          src/http/v3/ngx_http_v3_tables.h \
                          src/http/v3/ngx_http_v3_streams.h"
-        ngx_module_srcs="src/http/v3/ngx_http_v3_encode.c \
+        ngx_module_srcs="src/http/v3/ngx_http_v3.c \
+                         src/http/v3/ngx_http_v3_encode.c \
                          src/http/v3/ngx_http_v3_parse.c \
                          src/http/v3/ngx_http_v3_tables.c \
                          src/http/v3/ngx_http_v3_streams.c \
diff --git a/src/http/v3/ngx_http_v3.c b/src/http/v3/ngx_http_v3.c
new file mode 100644 (file)
index 0000000..461388b
--- /dev/null
@@ -0,0 +1,85 @@
+
+/*
+ * Copyright (C) Roman Arutyunyan
+ * Copyright (C) Nginx, Inc.
+ */
+
+
+#include <ngx_config.h>
+#include <ngx_core.h>
+#include <ngx_http.h>
+
+
+static void ngx_http_v3_keepalive_handler(ngx_event_t *ev);
+static void ngx_http_v3_cleanup_session(void *data);
+
+
+ngx_int_t
+ngx_http_v3_init_session(ngx_connection_t *c)
+{
+    ngx_connection_t       *pc;
+    ngx_pool_cleanup_t     *cln;
+    ngx_http_connection_t  *hc;
+    ngx_http_v3_session_t  *h3c;
+
+    pc = c->quic->parent;
+    hc = pc->data;
+
+    if (hc->v3_session) {
+        return NGX_OK;
+    }
+
+    ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 init session");
+
+    h3c = ngx_pcalloc(pc->pool, sizeof(ngx_http_v3_session_t));
+    if (h3c == NULL) {
+        return NGX_ERROR;
+    }
+
+    h3c->max_push_id = (uint64_t) -1;
+
+    ngx_queue_init(&h3c->blocked);
+    ngx_queue_init(&h3c->pushing);
+
+    h3c->keepalive.log = pc->log;
+    h3c->keepalive.data = pc;
+    h3c->keepalive.handler = ngx_http_v3_keepalive_handler;
+    h3c->keepalive.cancelable = 1;
+
+    cln = ngx_pool_cleanup_add(pc->pool, 0);
+    if (cln == NULL) {
+        return NGX_ERROR;
+    }
+
+    cln->handler = ngx_http_v3_cleanup_session;
+    cln->data = h3c;
+
+    hc->v3_session = h3c;
+
+    return ngx_http_v3_send_settings(c);
+}
+
+
+static void
+ngx_http_v3_keepalive_handler(ngx_event_t *ev)
+{
+    ngx_connection_t  *c;
+
+    c = ev->data;
+
+    ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 keepalive handler");
+
+    ngx_quic_finalize_connection(c, NGX_HTTP_V3_ERR_NO_ERROR,
+                                 "keepalive timeout");
+}
+
+
+static void
+ngx_http_v3_cleanup_session(void *data)
+{
+    ngx_http_v3_session_t  *h3c = data;
+
+    if (h3c->keepalive.timer_set) {
+        ngx_del_timer(&h3c->keepalive);
+    }
+}
index 292e6653beaa39134b49f9b0fbc655316cd3142b..0e55dbe0d39b3984b39a9a9eff1970326f0aa026 100644 (file)
@@ -24,86 +24,12 @@ typedef struct {
 } ngx_http_v3_push_t;
 
 
-static void ngx_http_v3_keepalive_handler(ngx_event_t *ev);
-static void ngx_http_v3_cleanup_session(void *data);
 static void ngx_http_v3_close_uni_stream(ngx_connection_t *c);
 static void ngx_http_v3_uni_read_handler(ngx_event_t *rev);
 static void ngx_http_v3_dummy_write_handler(ngx_event_t *wev);
 static void ngx_http_v3_push_cleanup(void *data);
 static ngx_connection_t *ngx_http_v3_get_uni_stream(ngx_connection_t *c,
     ngx_uint_t type);
-static ngx_int_t ngx_http_v3_send_settings(ngx_connection_t *c);
-
-
-ngx_int_t
-ngx_http_v3_init_session(ngx_connection_t *c)
-{
-    ngx_connection_t          *pc;
-    ngx_pool_cleanup_t        *cln;
-    ngx_http_connection_t     *hc;
-    ngx_http_v3_session_t     *h3c;
-
-    pc = c->quic->parent;
-    hc = pc->data;
-
-    if (hc->v3_session) {
-        return NGX_OK;
-    }
-
-    ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 init session");
-
-    h3c = ngx_pcalloc(pc->pool, sizeof(ngx_http_v3_session_t));
-    if (h3c == NULL) {
-        return NGX_ERROR;
-    }
-
-    h3c->max_push_id = (uint64_t) -1;
-
-    ngx_queue_init(&h3c->blocked);
-    ngx_queue_init(&h3c->pushing);
-
-    h3c->keepalive.log = pc->log;
-    h3c->keepalive.data = pc;
-    h3c->keepalive.handler = ngx_http_v3_keepalive_handler;
-    h3c->keepalive.cancelable = 1;
-
-    cln = ngx_pool_cleanup_add(pc->pool, 0);
-    if (cln == NULL) {
-        return NGX_ERROR;
-    }
-
-    cln->handler = ngx_http_v3_cleanup_session;
-    cln->data = h3c;
-
-    hc->v3_session = h3c;
-
-    return ngx_http_v3_send_settings(c);
-}
-
-
-static void
-ngx_http_v3_keepalive_handler(ngx_event_t *ev)
-{
-    ngx_connection_t  *c;
-
-    c = ev->data;
-
-    ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 keepalive handler");
-
-    ngx_quic_finalize_connection(c, NGX_HTTP_V3_ERR_NO_ERROR,
-                                 "keepalive timeout");
-}
-
-
-static void
-ngx_http_v3_cleanup_session(void *data)
-{
-    ngx_http_v3_session_t  *h3c = data;
-
-    if (h3c->keepalive.timer_set) {
-        ngx_del_timer(&h3c->keepalive);
-    }
-}
 
 
 void
@@ -445,7 +371,7 @@ failed:
 }
 
 
-static ngx_int_t
+ngx_int_t
 ngx_http_v3_send_settings(ngx_connection_t *c)
 {
     u_char                  *p, buf[NGX_HTTP_V3_VARLEN_INT_LEN * 6];
index c48e6425c84193d659144977b6055b32721e3d06..75325f5d4b1d91b0c6c9a01e2049977b61c10708 100644 (file)
@@ -24,6 +24,7 @@ ngx_int_t ngx_http_v3_set_max_push_id(ngx_connection_t *c,
 ngx_int_t ngx_http_v3_cancel_push(ngx_connection_t *c, uint64_t push_id);
 ngx_int_t ngx_http_v3_cancel_stream(ngx_connection_t *c, ngx_uint_t stream_id);
 
+ngx_int_t ngx_http_v3_send_settings(ngx_connection_t *c);
 ngx_int_t ngx_http_v3_send_goaway(ngx_connection_t *c, uint64_t id);
 ngx_int_t ngx_http_v3_send_ref_insert(ngx_connection_t *c, ngx_uint_t dynamic,
     ngx_uint_t index, ngx_str_t *value);