comparison src/http/v3/ngx_http_v3_streams.c @ 8495:455a8536eaa7 quic

QUIC: limited the number of server-initiated streams. Also, ngx_quic_create_uni_stream() is replaced with ngx_quic_open_stream() which is capable of creating a bidi stream.
author Roman Arutyunyan <arut@nginx.com>
date Mon, 27 Jul 2020 18:51:42 +0300
parents 65c1fc5fae15
children 0596fe1aee16
comparison
equal deleted inserted replaced
8494:e334ca1b23ba 8495:455a8536eaa7
53 53
54 c->data = h3c; 54 c->data = h3c;
55 return NGX_OK; 55 return NGX_OK;
56 } 56 }
57 57
58 h3c = c->qs->parent->data; 58 if (ngx_http_v3_send_settings(c) == NGX_ERROR) {
59 59 return NGX_ERROR;
60 if (!h3c->settings_sent) {
61 h3c->settings_sent = 1;
62
63 if (ngx_http_v3_send_settings(c) != NGX_OK) {
64 ngx_http_v3_finalize_connection(c, NGX_HTTP_V3_ERR_INTERNAL_ERROR,
65 "could not send settings");
66 return NGX_ERROR;
67 }
68 } 60 }
69 61
70 if ((c->qs->id & NGX_QUIC_STREAM_UNIDIRECTIONAL) == 0) { 62 if ((c->qs->id & NGX_QUIC_STREAM_UNIDIRECTIONAL) == 0) {
71 return NGX_OK; 63 return NGX_OK;
72 } 64 }
359 if (h3c->known_streams[index]) { 351 if (h3c->known_streams[index]) {
360 return h3c->known_streams[index]; 352 return h3c->known_streams[index];
361 } 353 }
362 } 354 }
363 355
364 sc = ngx_quic_create_uni_stream(c); 356 sc = ngx_quic_open_stream(c, 0);
365 if (sc == NULL) { 357 if (sc == NULL) {
366 return NULL; 358 return NULL;
367 } 359 }
368 360
369 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, 361 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0,
408 size_t n; 400 size_t n;
409 ngx_connection_t *cc; 401 ngx_connection_t *cc;
410 ngx_http_v3_srv_conf_t *h3scf; 402 ngx_http_v3_srv_conf_t *h3scf;
411 ngx_http_v3_connection_t *h3c; 403 ngx_http_v3_connection_t *h3c;
412 404
405 h3c = c->qs->parent->data;
406
407 if (h3c->settings_sent) {
408 return NGX_OK;
409 }
410
413 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 send settings"); 411 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 send settings");
414 412
415 cc = ngx_http_v3_get_uni_stream(c, NGX_HTTP_V3_STREAM_CONTROL); 413 cc = ngx_http_v3_get_uni_stream(c, NGX_HTTP_V3_STREAM_CONTROL);
416 if (cc == NULL) { 414 if (cc == NULL) {
417 return NGX_ERROR; 415 return NGX_DECLINED;
418 } 416 }
419 417
420 h3c = c->qs->parent->data;
421 h3scf = ngx_http_get_module_srv_conf(h3c->hc.conf_ctx, ngx_http_v3_module); 418 h3scf = ngx_http_get_module_srv_conf(h3c->hc.conf_ctx, ngx_http_v3_module);
422 419
423 n = ngx_http_v3_encode_varlen_int(NULL, 420 n = ngx_http_v3_encode_varlen_int(NULL,
424 NGX_HTTP_V3_PARAM_MAX_TABLE_CAPACITY); 421 NGX_HTTP_V3_PARAM_MAX_TABLE_CAPACITY);
425 n += ngx_http_v3_encode_varlen_int(NULL, h3scf->max_table_capacity); 422 n += ngx_http_v3_encode_varlen_int(NULL, h3scf->max_table_capacity);
439 436
440 if (cc->send(cc, buf, n) != (ssize_t) n) { 437 if (cc->send(cc, buf, n) != (ssize_t) n) {
441 goto failed; 438 goto failed;
442 } 439 }
443 440
441 h3c->settings_sent = 1;
442
444 return NGX_OK; 443 return NGX_OK;
445 444
446 failed: 445 failed:
447 446
448 ngx_http_v3_close_uni_stream(cc); 447 ngx_http_v3_close_uni_stream(cc);
448
449 ngx_http_v3_finalize_connection(c, NGX_HTTP_V3_ERR_INTERNAL_ERROR,
450 "could not send settings");
449 451
450 return NGX_ERROR; 452 return NGX_ERROR;
451 } 453 }
452 454
453 455