comparison src/http/v3/ngx_http_v3_streams.c @ 8903:0d3bf08eaac0 quic

HTTP/3: allowed QUIC stream connection reuse. A QUIC stream connection is treated as reusable until first bytes of request arrive, which is also when the request object is now allocated. A connection closed as a result of draining, is reset with the error code H3_REQUEST_REJECTED. Such behavior is allowed by quic-http-34: Once a request stream has been opened, the request MAY be cancelled by either endpoint. Clients cancel requests if the response is no longer of interest; servers cancel requests if they are unable to or choose not to respond. When the server cancels a request without performing any application processing, the request is considered "rejected." The server SHOULD abort its response stream with the error code H3_REQUEST_REJECTED. The client can treat requests rejected by the server as though they had never been sent at all, thereby allowing them to be retried later.
author Roman Arutyunyan <arut@nginx.com>
date Mon, 18 Oct 2021 15:47:06 +0300
parents 925572184d4a
children d6ef13c5fd8e
comparison
equal deleted inserted replaced
8902:925572184d4a 8903:0d3bf08eaac0
47 47
48 if (n >= h3scf->max_uni_streams) { 48 if (n >= h3scf->max_uni_streams) {
49 ngx_http_v3_finalize_connection(c, 49 ngx_http_v3_finalize_connection(c,
50 NGX_HTTP_V3_ERR_STREAM_CREATION_ERROR, 50 NGX_HTTP_V3_ERR_STREAM_CREATION_ERROR,
51 "reached maximum number of uni streams"); 51 "reached maximum number of uni streams");
52 ngx_http_close_connection(c); 52 c->data = NULL;
53 ngx_http_v3_close_uni_stream(c);
53 return; 54 return;
54 } 55 }
55 56
56 c->quic->cancelable = 1; 57 c->quic->cancelable = 1;
57 58
58 us = ngx_pcalloc(c->pool, sizeof(ngx_http_v3_uni_stream_t)); 59 us = ngx_pcalloc(c->pool, sizeof(ngx_http_v3_uni_stream_t));
59 if (us == NULL) { 60 if (us == NULL) {
60 ngx_http_close_connection(c); 61 ngx_http_v3_finalize_connection(c,
62 NGX_HTTP_V3_ERR_INTERNAL_ERROR,
63 "memory allocation error");
64 c->data = NULL;
65 ngx_http_v3_close_uni_stream(c);
61 return; 66 return;
62 } 67 }
63 68
64 us->index = -1; 69 us->index = -1;
65 70
77 { 82 {
78 ngx_pool_t *pool; 83 ngx_pool_t *pool;
79 ngx_http_v3_session_t *h3c; 84 ngx_http_v3_session_t *h3c;
80 ngx_http_v3_uni_stream_t *us; 85 ngx_http_v3_uni_stream_t *us;
81 86
87 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 close stream");
88
82 us = c->data; 89 us = c->data;
83 h3c = ngx_http_v3_get_session(c); 90
84 91 if (us && us->index >= 0) {
85 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 close stream"); 92 h3c = ngx_http_v3_get_session(c);
86
87 if (us->index >= 0) {
88 h3c->known_streams[us->index] = NULL; 93 h3c->known_streams[us->index] = NULL;
89 } 94 }
90 95
91 c->destroyed = 1; 96 c->destroyed = 1;
92 97