Mercurial > hg > nginx
comparison src/event/quic/ngx_event_quic.c @ 8703:d710c457171c quic
QUIC: added ability to reset a stream.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Wed, 17 Feb 2021 14:25:07 +0300 |
parents | d4e02b3b734f |
children | 98bacfc65c61 |
comparison
equal
deleted
inserted
replaced
8702:d4e02b3b734f | 8703:d710c457171c |
---|---|
2201 | 2201 |
2202 return NGX_AGAIN; | 2202 return NGX_AGAIN; |
2203 } | 2203 } |
2204 | 2204 |
2205 | 2205 |
2206 ngx_int_t | |
2207 ngx_quic_reset_stream(ngx_connection_t *c, ngx_uint_t err) | |
2208 { | |
2209 ngx_event_t *wev; | |
2210 ngx_connection_t *pc; | |
2211 ngx_quic_frame_t *frame; | |
2212 ngx_quic_stream_t *qs; | |
2213 ngx_quic_connection_t *qc; | |
2214 | |
2215 qs = c->quic; | |
2216 pc = qs->parent; | |
2217 qc = ngx_quic_get_connection(pc); | |
2218 | |
2219 frame = ngx_quic_alloc_frame(pc); | |
2220 if (frame == NULL) { | |
2221 return NGX_ERROR; | |
2222 } | |
2223 | |
2224 frame->level = ssl_encryption_application; | |
2225 frame->type = NGX_QUIC_FT_RESET_STREAM; | |
2226 frame->u.reset_stream.id = qs->id; | |
2227 frame->u.reset_stream.error_code = err; | |
2228 frame->u.reset_stream.final_size = c->sent; | |
2229 | |
2230 ngx_quic_queue_frame(qc, frame); | |
2231 | |
2232 wev = c->write; | |
2233 wev->error = 1; | |
2234 wev->ready = 1; | |
2235 | |
2236 return NGX_OK; | |
2237 } | |
2238 | |
2239 | |
2206 static ngx_int_t | 2240 static ngx_int_t |
2207 ngx_quic_input(ngx_connection_t *c, ngx_buf_t *b, ngx_quic_conf_t *conf) | 2241 ngx_quic_input(ngx_connection_t *c, ngx_buf_t *b, ngx_quic_conf_t *conf) |
2208 { | 2242 { |
2209 u_char *p; | 2243 u_char *p; |
2210 ngx_int_t rc; | 2244 ngx_int_t rc; |
6406 /* do not send fin for client unidirectional streams */ | 6440 /* do not send fin for client unidirectional streams */ |
6407 return; | 6441 return; |
6408 } | 6442 } |
6409 } | 6443 } |
6410 | 6444 |
6445 if (c->write->error) { | |
6446 goto error; | |
6447 } | |
6448 | |
6411 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, | 6449 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
6412 "quic stream id:0x%xL send fin", qs->id); | 6450 "quic stream id:0x%xL send fin", qs->id); |
6413 | 6451 |
6414 frame = ngx_quic_alloc_frame(pc); | 6452 frame = ngx_quic_alloc_frame(pc); |
6415 if (frame == NULL) { | 6453 if (frame == NULL) { |
6426 frame->u.stream.stream_id = qs->id; | 6464 frame->u.stream.stream_id = qs->id; |
6427 frame->u.stream.offset = c->sent; | 6465 frame->u.stream.offset = c->sent; |
6428 frame->u.stream.length = 0; | 6466 frame->u.stream.length = 0; |
6429 | 6467 |
6430 ngx_quic_queue_frame(qc, frame); | 6468 ngx_quic_queue_frame(qc, frame); |
6469 | |
6470 error: | |
6431 | 6471 |
6432 (void) ngx_quic_output(pc); | 6472 (void) ngx_quic_output(pc); |
6433 } | 6473 } |
6434 | 6474 |
6435 | 6475 |