comparison src/http/v3/ngx_http_v3_streams.c @ 8768:40d710a66aef quic

HTTP/3: ngx_http_v3_get_session() macro. It's used instead of accessing c->quic->parent->data directly. Apart from being simpler, it allows to change the way session is stored in the future by changing the macro.
author Roman Arutyunyan <arut@nginx.com>
date Fri, 30 Apr 2021 19:10:11 +0300
parents 33ec97749b5f
children 9ec3e71f8a61
comparison
equal deleted inserted replaced
8767:33ec97749b5f 8768:40d710a66aef
146 ngx_pool_t *pool; 146 ngx_pool_t *pool;
147 ngx_http_v3_connection_t *h3c; 147 ngx_http_v3_connection_t *h3c;
148 ngx_http_v3_uni_stream_t *us; 148 ngx_http_v3_uni_stream_t *us;
149 149
150 us = c->data; 150 us = c->data;
151 h3c = c->quic->parent->data; 151 h3c = ngx_http_v3_get_session(c);
152 152
153 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 close stream"); 153 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 close stream");
154 154
155 if (us->index >= 0) { 155 if (us->index >= 0) {
156 h3c->known_streams[us->index] = NULL; 156 h3c->known_streams[us->index] = NULL;
176 ngx_http_v3_connection_t *h3c; 176 ngx_http_v3_connection_t *h3c;
177 ngx_http_v3_uni_stream_t *us; 177 ngx_http_v3_uni_stream_t *us;
178 178
179 c = rev->data; 179 c = rev->data;
180 us = c->data; 180 us = c->data;
181 h3c = c->quic->parent->data; 181 h3c = ngx_http_v3_get_session(c);
182 182
183 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 read stream type"); 183 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 read stream type");
184 184
185 while (rev->ready) { 185 while (rev->ready) {
186 186
408 cln = ngx_pool_cleanup_add(sc->pool, sizeof(ngx_http_v3_push_t)); 408 cln = ngx_pool_cleanup_add(sc->pool, sizeof(ngx_http_v3_push_t));
409 if (cln == NULL) { 409 if (cln == NULL) {
410 goto failed; 410 goto failed;
411 } 411 }
412 412
413 h3c = c->quic->parent->data; 413 h3c = ngx_http_v3_get_session(c);
414 h3c->npushing++; 414 h3c->npushing++;
415 415
416 cln->handler = ngx_http_v3_push_cleanup; 416 cln->handler = ngx_http_v3_push_cleanup;
417 417
418 push = cln->data; 418 push = cln->data;
464 break; 464 break;
465 default: 465 default:
466 index = -1; 466 index = -1;
467 } 467 }
468 468
469 h3c = c->quic->parent->data; 469 h3c = ngx_http_v3_get_session(c);
470 470
471 if (index >= 0) { 471 if (index >= 0) {
472 if (h3c->known_streams[index]) { 472 if (h3c->known_streams[index]) {
473 return h3c->known_streams[index]; 473 return h3c->known_streams[index];
474 } 474 }
523 size_t n; 523 size_t n;
524 ngx_connection_t *cc; 524 ngx_connection_t *cc;
525 ngx_http_v3_srv_conf_t *h3scf; 525 ngx_http_v3_srv_conf_t *h3scf;
526 ngx_http_v3_connection_t *h3c; 526 ngx_http_v3_connection_t *h3c;
527 527
528 h3c = c->quic->parent->data; 528 h3c = ngx_http_v3_get_session(c);
529 529
530 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 send settings"); 530 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 send settings");
531 531
532 cc = ngx_http_v3_get_uni_stream(c, NGX_HTTP_V3_STREAM_CONTROL); 532 cc = ngx_http_v3_get_uni_stream(c, NGX_HTTP_V3_STREAM_CONTROL);
533 if (cc == NULL) { 533 if (cc == NULL) {
835 ngx_int_t 835 ngx_int_t
836 ngx_http_v3_set_max_push_id(ngx_connection_t *c, uint64_t max_push_id) 836 ngx_http_v3_set_max_push_id(ngx_connection_t *c, uint64_t max_push_id)
837 { 837 {
838 ngx_http_v3_connection_t *h3c; 838 ngx_http_v3_connection_t *h3c;
839 839
840 h3c = c->quic->parent->data; 840 h3c = ngx_http_v3_get_session(c);
841 841
842 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, 842 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0,
843 "http3 MAX_PUSH_ID:%uL", max_push_id); 843 "http3 MAX_PUSH_ID:%uL", max_push_id);
844 844
845 if (h3c->max_push_id != (uint64_t) -1 && max_push_id < h3c->max_push_id) { 845 if (h3c->max_push_id != (uint64_t) -1 && max_push_id < h3c->max_push_id) {
858 ngx_queue_t *q; 858 ngx_queue_t *q;
859 ngx_http_request_t *r; 859 ngx_http_request_t *r;
860 ngx_http_v3_push_t *push; 860 ngx_http_v3_push_t *push;
861 ngx_http_v3_connection_t *h3c; 861 ngx_http_v3_connection_t *h3c;
862 862
863 h3c = c->quic->parent->data; 863 h3c = ngx_http_v3_get_session(c);
864 864
865 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, 865 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0,
866 "http3 CANCEL_PUSH:%uL", push_id); 866 "http3 CANCEL_PUSH:%uL", push_id);
867 867
868 if (push_id >= h3c->next_push_id) { 868 if (push_id >= h3c->next_push_id) {