aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/event/ngx_event_udp.c7
-rw-r--r--src/event/quic/ngx_event_quic.c29
-rw-r--r--src/event/quic/ngx_event_quic.h3
3 files changed, 24 insertions, 15 deletions
diff --git a/src/event/ngx_event_udp.c b/src/event/ngx_event_udp.c
index ca70e3bd6..95895571d 100644
--- a/src/event/ngx_event_udp.c
+++ b/src/event/ngx_event_udp.c
@@ -684,6 +684,13 @@ ngx_lookup_udp_connection(ngx_listening_t *ls, ngx_str_t *key,
}
if (rc == 0) {
+
+#if (NGX_QUIC)
+ if (ls->quic && c->udp != udp) {
+ c->udp = udp;
+ }
+#endif
+
return c;
}
diff --git a/src/event/quic/ngx_event_quic.c b/src/event/quic/ngx_event_quic.c
index 77f0eeda8..d07c3ed49 100644
--- a/src/event/quic/ngx_event_quic.c
+++ b/src/event/quic/ngx_event_quic.c
@@ -112,8 +112,6 @@ typedef struct {
typedef struct {
- ngx_udp_connection_t udp;
-
uint32_t version;
ngx_str_t scid; /* initial client ID */
ngx_str_t dcid; /* server (our own) ID */
@@ -198,6 +196,7 @@ typedef struct {
typedef struct {
ngx_udp_connection_t udp;
+ ngx_quic_connection_t *quic;
ngx_queue_t queue;
uint64_t seqnum;
size_t len;
@@ -342,7 +341,7 @@ static ngx_int_t ngx_quic_handle_retire_connection_id_frame(ngx_connection_t *c,
static ngx_int_t ngx_quic_issue_server_ids(ngx_connection_t *c);
static void ngx_quic_clear_temp_server_ids(ngx_connection_t *c);
static ngx_quic_server_id_t *ngx_quic_insert_server_id(ngx_connection_t *c,
- ngx_str_t *id);
+ ngx_quic_connection_t *qc, ngx_str_t *id);
static ngx_quic_client_id_t *ngx_quic_alloc_client_id(ngx_connection_t *c,
ngx_quic_connection_t *qc);
static ngx_quic_server_id_t *ngx_quic_alloc_server_id(ngx_connection_t *c,
@@ -1096,6 +1095,7 @@ ngx_quic_new_connection(ngx_connection_t *c, ngx_quic_conf_t *conf,
{
ngx_uint_t i;
ngx_quic_tp_t *ctp;
+ ngx_quic_server_id_t *sid;
ngx_quic_client_id_t *cid;
ngx_quic_connection_t *qc;
@@ -1247,18 +1247,19 @@ ngx_quic_new_connection(ngx_connection_t *c, ngx_quic_conf_t *conf,
return NULL;
}
- c->udp = &qc->udp;
-
- if (ngx_quic_insert_server_id(c, &qc->odcid) == NULL) {
+ if (ngx_quic_insert_server_id(c, qc, &qc->odcid) == NULL) {
return NULL;
}
qc->server_seqnum = 0;
- if (ngx_quic_insert_server_id(c, &qc->dcid) == NULL) {
+ sid = ngx_quic_insert_server_id(c, qc, &qc->dcid);
+ if (sid == NULL) {
return NULL;
}
+ c->udp = &sid->udp;
+
qc->validated = pkt->validated;
return qc;
@@ -4777,7 +4778,7 @@ ngx_quic_issue_server_ids(ngx_connection_t *c)
dcid.len = NGX_QUIC_SERVER_CID_LEN;
dcid.data = id;
- sid = ngx_quic_insert_server_id(c, &dcid);
+ sid = ngx_quic_insert_server_id(c, qc, &dcid);
if (sid == NULL) {
return NGX_ERROR;
}
@@ -4840,19 +4841,19 @@ ngx_quic_clear_temp_server_ids(ngx_connection_t *c)
static ngx_quic_server_id_t *
-ngx_quic_insert_server_id(ngx_connection_t *c, ngx_str_t *id)
+ngx_quic_insert_server_id(ngx_connection_t *c, ngx_quic_connection_t *qc,
+ ngx_str_t *id)
{
- ngx_str_t dcid;
- ngx_quic_server_id_t *sid;
- ngx_quic_connection_t *qc;
-
- qc = ngx_quic_get_connection(c);
+ ngx_str_t dcid;
+ ngx_quic_server_id_t *sid;
sid = ngx_quic_alloc_server_id(c, qc);
if (sid == NULL) {
return NULL;
}
+ sid->quic = qc;
+
sid->seqnum = qc->server_seqnum;
if (qc->server_seqnum != NGX_QUIC_UNSET_PN) {
diff --git a/src/event/quic/ngx_event_quic.h b/src/event/quic/ngx_event_quic.h
index 0a38d911c..865e5f08c 100644
--- a/src/event/quic/ngx_event_quic.h
+++ b/src/event/quic/ngx_event_quic.h
@@ -64,7 +64,8 @@
#define NGX_QUIC_BUFFER_SIZE 4096
-#define ngx_quic_get_connection(c) ((ngx_quic_connection_t *)(c)->udp)
+#define ngx_quic_get_connection(c) \
+ (((c)->udp) ? (((ngx_quic_server_id_t *)((c)->udp))->quic) : NULL)
typedef struct {