comparison src/event/ngx_event_quic.c @ 8505:240931629995 quic

QUIC: handle client RESET_STREAM and STOP_SENDING. For RESET_STREAM the c->read->error flag is set. For STOP_SENDING the c->write->error flag is set.
author Roman Arutyunyan <arut@nginx.com>
date Mon, 03 Aug 2020 13:31:48 +0300
parents d277e25e37fc
children 03ec6ab67752
comparison
equal deleted inserted replaced
8504:d277e25e37fc 8505:240931629995
3178 3178
3179 static ngx_int_t 3179 static ngx_int_t
3180 ngx_quic_handle_reset_stream_frame(ngx_connection_t *c, 3180 ngx_quic_handle_reset_stream_frame(ngx_connection_t *c,
3181 ngx_quic_header_t *pkt, ngx_quic_reset_stream_frame_t *f) 3181 ngx_quic_header_t *pkt, ngx_quic_reset_stream_frame_t *f)
3182 { 3182 {
3183 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0, 3183 ngx_event_t *rev;
3184 "quic frame handler not implemented"); 3184 ngx_connection_t *sc;
3185 ngx_quic_stream_t *sn;
3186 ngx_quic_connection_t *qc;
3187
3188 qc = c->quic;
3185 3189
3186 if ((f->id & NGX_QUIC_STREAM_UNIDIRECTIONAL) 3190 if ((f->id & NGX_QUIC_STREAM_UNIDIRECTIONAL)
3187 && (f->id & NGX_QUIC_STREAM_SERVER_INITIATED)) 3191 && (f->id & NGX_QUIC_STREAM_SERVER_INITIATED))
3188 { 3192 {
3189 c->quic->error = NGX_QUIC_ERR_STREAM_STATE_ERROR; 3193 qc->error = NGX_QUIC_ERR_STREAM_STATE_ERROR;
3190 return NGX_ERROR; 3194 return NGX_ERROR;
3195 }
3196
3197 sn = ngx_quic_find_stream(&qc->streams.tree, f->id);
3198
3199 if (sn == NULL) {
3200 sn = ngx_quic_create_client_stream(c, f->id);
3201
3202 if (sn == NULL) {
3203 return NGX_ERROR;
3204 }
3205
3206 if (sn == NGX_QUIC_STREAM_GONE) {
3207 return NGX_OK;
3208 }
3209
3210 sc = sn->c;
3211
3212 rev = sc->read;
3213 rev->error = 1;
3214 rev->ready = 1;
3215
3216 sc->listening->handler(sc);
3217
3218 return NGX_OK;
3219 }
3220
3221 rev = sn->c->read;
3222 rev->error = 1;
3223 rev->ready = 1;
3224
3225 if (rev->active) {
3226 rev->handler(rev);
3191 } 3227 }
3192 3228
3193 return NGX_OK; 3229 return NGX_OK;
3194 } 3230 }
3195 3231
3196 3232
3197 static ngx_int_t 3233 static ngx_int_t
3198 ngx_quic_handle_stop_sending_frame(ngx_connection_t *c, 3234 ngx_quic_handle_stop_sending_frame(ngx_connection_t *c,
3199 ngx_quic_header_t *pkt, ngx_quic_stop_sending_frame_t *f) 3235 ngx_quic_header_t *pkt, ngx_quic_stop_sending_frame_t *f)
3200 { 3236 {
3237 ngx_event_t *wev;
3238 ngx_connection_t *sc;
3201 ngx_quic_stream_t *sn; 3239 ngx_quic_stream_t *sn;
3202 ngx_quic_connection_t *qc; 3240 ngx_quic_connection_t *qc;
3203
3204 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0,
3205 "quic frame handler not implemented");
3206 3241
3207 qc = c->quic; 3242 qc = c->quic;
3208 3243
3209 if ((f->id & NGX_QUIC_STREAM_UNIDIRECTIONAL) 3244 if ((f->id & NGX_QUIC_STREAM_UNIDIRECTIONAL)
3210 && (f->id & NGX_QUIC_STREAM_SERVER_INITIATED) == 0) 3245 && (f->id & NGX_QUIC_STREAM_SERVER_INITIATED) == 0)
3214 } 3249 }
3215 3250
3216 sn = ngx_quic_find_stream(&qc->streams.tree, f->id); 3251 sn = ngx_quic_find_stream(&qc->streams.tree, f->id);
3217 3252
3218 if (sn == NULL) { 3253 if (sn == NULL) {
3219 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, 3254 sn = ngx_quic_create_client_stream(c, f->id);
3220 "quic stream id 0x%xL is new", f->id); 3255
3221 3256 if (sn == NULL) {
3222 if (f->id & NGX_QUIC_STREAM_SERVER_INITIATED) {
3223 qc->error = NGX_QUIC_ERR_STREAM_STATE_ERROR;
3224 return NGX_ERROR; 3257 return NGX_ERROR;
3225 } 3258 }
3259
3260 if (sn == NGX_QUIC_STREAM_GONE) {
3261 return NGX_OK;
3262 }
3263
3264 sc = sn->c;
3265
3266 wev = sc->write;
3267 wev->error = 1;
3268 wev->ready = 1;
3269
3270 sc->listening->handler(sc);
3271
3272 return NGX_OK;
3273 }
3274
3275 wev = sn->c->write;
3276 wev->error = 1;
3277 wev->ready = 1;
3278
3279 if (wev->active) {
3280 wev->handler(wev);
3226 } 3281 }
3227 3282
3228 return NGX_OK; 3283 return NGX_OK;
3229 } 3284 }
3230 3285