comparison src/http/v3/ngx_http_v3_streams.c @ 8358:265062a99043 quic

HTTP/3: send GOAWAY when last request is accepted. The last request in connection is determined according to the keepalive_requests directive. Requests beyond keepalive_requests are rejected.
author Roman Arutyunyan <arut@nginx.com>
date Mon, 15 Mar 2021 19:26:04 +0300
parents 5cb5b568282b
children fc64ab301bad
comparison
equal deleted inserted replaced
8357:7a07724256c2 8358:265062a99043
521 return NGX_ERROR; 521 return NGX_ERROR;
522 } 522 }
523 523
524 524
525 ngx_int_t 525 ngx_int_t
526 ngx_http_v3_send_goaway(ngx_connection_t *c, uint64_t id)
527 {
528 u_char *p, buf[NGX_HTTP_V3_VARLEN_INT_LEN * 3];
529 size_t n;
530 ngx_connection_t *cc;
531
532 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 send goaway %uL", id);
533
534 cc = ngx_http_v3_get_uni_stream(c, NGX_HTTP_V3_STREAM_CONTROL);
535 if (cc == NULL) {
536 return NGX_DECLINED;
537 }
538
539 n = ngx_http_v3_encode_varlen_int(NULL, id);
540 p = (u_char *) ngx_http_v3_encode_varlen_int(buf, NGX_HTTP_V3_FRAME_GOAWAY);
541 p = (u_char *) ngx_http_v3_encode_varlen_int(p, n);
542 p = (u_char *) ngx_http_v3_encode_varlen_int(p, id);
543 n = p - buf;
544
545 if (cc->send(cc, buf, n) != (ssize_t) n) {
546 goto failed;
547 }
548
549 return NGX_OK;
550
551 failed:
552
553 ngx_http_v3_close_uni_stream(cc);
554
555 return NGX_ERROR;
556 }
557
558
559 ngx_int_t
526 ngx_http_v3_client_ref_insert(ngx_connection_t *c, ngx_uint_t dynamic, 560 ngx_http_v3_client_ref_insert(ngx_connection_t *c, ngx_uint_t dynamic,
527 ngx_uint_t index, ngx_str_t *value) 561 ngx_uint_t index, ngx_str_t *value)
528 { 562 {
529 u_char *p, buf[NGX_HTTP_V3_PREFIX_INT_LEN * 2]; 563 u_char *p, buf[NGX_HTTP_V3_PREFIX_INT_LEN * 2];
530 size_t n; 564 size_t n;