comparison src/http/v3/ngx_http_v3_streams.c @ 8281:618a65de08b3 quic

When closing a QUIC connection, wait for all streams to finish. Additionally, streams are now removed from the tree in cleanup handler.
author Roman Arutyunyan <arut@nginx.com>
date Tue, 24 Mar 2020 18:05:45 +0300
parents ac41c53e446d
children dadbc66e9fca
comparison
equal deleted inserted replaced
8280:b364af7f9f3f 8281:618a65de08b3
27 27
28 static void ngx_http_v3_close_uni_stream(ngx_connection_t *c); 28 static void ngx_http_v3_close_uni_stream(ngx_connection_t *c);
29 static void ngx_http_v3_uni_stream_cleanup(void *data); 29 static void ngx_http_v3_uni_stream_cleanup(void *data);
30 static void ngx_http_v3_read_uni_stream_type(ngx_event_t *rev); 30 static void ngx_http_v3_read_uni_stream_type(ngx_event_t *rev);
31 static void ngx_http_v3_uni_read_handler(ngx_event_t *rev); 31 static void ngx_http_v3_uni_read_handler(ngx_event_t *rev);
32 static void ngx_http_v3_dummy_write_handler(ngx_event_t *wev);
32 static ngx_connection_t *ngx_http_v3_create_uni_stream(ngx_connection_t *c, 33 static ngx_connection_t *ngx_http_v3_create_uni_stream(ngx_connection_t *c,
33 ngx_uint_t type); 34 ngx_uint_t type);
34 static ngx_connection_t *ngx_http_v3_get_control(ngx_connection_t *c); 35 static ngx_connection_t *ngx_http_v3_get_control(ngx_connection_t *c);
35 static ngx_connection_t *ngx_http_v3_get_encoder(ngx_connection_t *c); 36 static ngx_connection_t *ngx_http_v3_get_encoder(ngx_connection_t *c);
36 static ngx_connection_t *ngx_http_v3_get_decoder(ngx_connection_t *c); 37 static ngx_connection_t *ngx_http_v3_get_decoder(ngx_connection_t *c);
72 73
73 cln->handler = ngx_http_v3_uni_stream_cleanup; 74 cln->handler = ngx_http_v3_uni_stream_cleanup;
74 cln->data = c; 75 cln->data = c;
75 76
76 c->read->handler = ngx_http_v3_read_uni_stream_type; 77 c->read->handler = ngx_http_v3_read_uni_stream_type;
78 c->write->handler = ngx_http_v3_dummy_write_handler;
79
77 ngx_http_v3_read_uni_stream_type(c->read); 80 ngx_http_v3_read_uni_stream_type(c->read);
78 } 81 }
79 82
80 83
81 static void 84 static void
308 311
309 ngx_http_v3_close_uni_stream(c); 312 ngx_http_v3_close_uni_stream(c);
310 } 313 }
311 314
312 315
316 static void
317 ngx_http_v3_dummy_write_handler(ngx_event_t *wev)
318 {
319 ngx_connection_t *c;
320
321 c = wev->data;
322
323 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 dummy write handler");
324
325 if (ngx_handle_write_event(wev, 0) != NGX_OK) {
326 ngx_http_v3_close_uni_stream(c);
327 }
328 }
329
330
313 /* XXX async & buffered stream writes */ 331 /* XXX async & buffered stream writes */
314 332
315 static ngx_connection_t * 333 static ngx_connection_t *
316 ngx_http_v3_create_uni_stream(ngx_connection_t *c, ngx_uint_t type) 334 ngx_http_v3_create_uni_stream(ngx_connection_t *c, ngx_uint_t type)
317 { 335 {
336 354
337 us->signature = NGX_HTTP_V3_STREAM; 355 us->signature = NGX_HTTP_V3_STREAM;
338 us->type = type; 356 us->type = type;
339 sc->data = us; 357 sc->data = us;
340 358
359 sc->read->handler = ngx_http_v3_uni_read_handler;
360 sc->write->handler = ngx_http_v3_dummy_write_handler;
361
341 cln = ngx_pool_cleanup_add(sc->pool, 0); 362 cln = ngx_pool_cleanup_add(sc->pool, 0);
342 if (cln == NULL) { 363 if (cln == NULL) {
343 goto failed; 364 goto failed;
344 } 365 }
345 366