comparison src/http/v3/ngx_http_v3.c @ 8902:925572184d4a quic

HTTP/3: adjusted QUIC connection finalization. When an HTTP/3 function returns an error in context of a QUIC stream, it's this function's responsibility now to finalize the entire QUIC connection with the right code, if required. Previously, QUIC connection finalization could be done both outside and inside such functions. The new rule follows a similar rule for logging, leads to cleaner code, and allows to provide more details about the error. While here, a few error cases are no longer treated as fatal and QUIC connection is no longer finalized in these cases. A few other cases now lead to stream reset instead of connection finalization.
author Roman Arutyunyan <arut@nginx.com>
date Mon, 18 Oct 2021 15:22:33 +0300
parents 72b304f6207c
children 6434160b4b78
comparison
equal deleted inserted replaced
8901:a951e0809044 8902:925572184d4a
31 31
32 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 init session"); 32 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 init session");
33 33
34 h3c = ngx_pcalloc(pc->pool, sizeof(ngx_http_v3_session_t)); 34 h3c = ngx_pcalloc(pc->pool, sizeof(ngx_http_v3_session_t));
35 if (h3c == NULL) { 35 if (h3c == NULL) {
36 return NGX_ERROR; 36 goto failed;
37 } 37 }
38 38
39 h3c->max_push_id = (uint64_t) -1; 39 h3c->max_push_id = (uint64_t) -1;
40 h3c->goaway_push_id = (uint64_t) -1; 40 h3c->goaway_push_id = (uint64_t) -1;
41 41
47 h3c->keepalive.handler = ngx_http_v3_keepalive_handler; 47 h3c->keepalive.handler = ngx_http_v3_keepalive_handler;
48 h3c->keepalive.cancelable = 1; 48 h3c->keepalive.cancelable = 1;
49 49
50 cln = ngx_pool_cleanup_add(pc->pool, 0); 50 cln = ngx_pool_cleanup_add(pc->pool, 0);
51 if (cln == NULL) { 51 if (cln == NULL) {
52 return NGX_ERROR; 52 goto failed;
53 } 53 }
54 54
55 cln->handler = ngx_http_v3_cleanup_session; 55 cln->handler = ngx_http_v3_cleanup_session;
56 cln->data = h3c; 56 cln->data = h3c;
57 57
58 hc->v3_session = h3c; 58 hc->v3_session = h3c;
59 59
60 return ngx_http_v3_send_settings(c); 60 return ngx_http_v3_send_settings(c);
61
62 failed:
63
64 ngx_log_error(NGX_LOG_ERR, c->log, 0, "failed to create http3 session");
65
66 ngx_http_v3_finalize_connection(c, NGX_HTTP_V3_ERR_INTERNAL_ERROR,
67 "failed to create http3 session");
68 return NGX_ERROR;
61 } 69 }
62 70
63 71
64 static void 72 static void
65 ngx_http_v3_keepalive_handler(ngx_event_t *ev) 73 ngx_http_v3_keepalive_handler(ngx_event_t *ev)