Mercurial > hg > nginx-quic
comparison src/event/quic/ngx_event_quic_streams.c @ 9012:03897c45798e quic
QUIC: defer setting the active flag for client stream events.
Specifically, now it is kept unset until streams are initialized.
Notably, this unbreaks OCSP with client certificates after 35e27117b593.
Previously, the read event could be posted prematurely via ngx_quic_set_event()
e.g., as part of handling a STREAM frame.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Wed, 18 Jan 2023 19:20:18 +0400 |
parents | 2ee6f9729739 |
children | 12b756caaf16 |
comparison
equal
deleted
inserted
replaced
9011:bf2267887014 | 9012:03897c45798e |
---|---|
44 | 44 |
45 ngx_connection_t * | 45 ngx_connection_t * |
46 ngx_quic_open_stream(ngx_connection_t *c, ngx_uint_t bidi) | 46 ngx_quic_open_stream(ngx_connection_t *c, ngx_uint_t bidi) |
47 { | 47 { |
48 uint64_t id; | 48 uint64_t id; |
49 ngx_connection_t *pc; | 49 ngx_connection_t *pc, *sc; |
50 ngx_quic_stream_t *nqs; | 50 ngx_quic_stream_t *qs; |
51 ngx_quic_connection_t *qc; | 51 ngx_quic_connection_t *qc; |
52 | 52 |
53 pc = c->quic ? c->quic->parent : c; | 53 pc = c->quic ? c->quic->parent : c; |
54 qc = ngx_quic_get_connection(pc); | 54 qc = ngx_quic_get_connection(pc); |
55 | 55 |
99 qc->streams.server_max_streams_uni, id); | 99 qc->streams.server_max_streams_uni, id); |
100 | 100 |
101 qc->streams.server_streams_uni++; | 101 qc->streams.server_streams_uni++; |
102 } | 102 } |
103 | 103 |
104 nqs = ngx_quic_create_stream(pc, id); | 104 qs = ngx_quic_create_stream(pc, id); |
105 if (nqs == NULL) { | 105 if (qs == NULL) { |
106 return NULL; | 106 return NULL; |
107 } | 107 } |
108 | 108 |
109 return nqs->connection; | 109 sc = qs->connection; |
110 | |
111 sc->write->active = 1; | |
112 sc->write->ready = 1; | |
113 | |
114 if (bidi) { | |
115 sc->read->active = 1; | |
116 } | |
117 | |
118 return sc; | |
110 } | 119 } |
111 | 120 |
112 | 121 |
113 void | 122 void |
114 ngx_quic_rbtree_insert_stream(ngx_rbtree_node_t *temp, | 123 ngx_quic_rbtree_insert_stream(ngx_rbtree_node_t *temp, |
531 | 540 |
532 c = ev->data; | 541 c = ev->data; |
533 qs = c->quic; | 542 qs = c->quic; |
534 | 543 |
535 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0, "quic init stream"); | 544 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0, "quic init stream"); |
545 | |
546 if ((qs->id & NGX_QUIC_STREAM_UNIDIRECTIONAL) == 0) { | |
547 c->write->active = 1; | |
548 c->write->ready = 1; | |
549 } | |
550 | |
551 c->read->active = 1; | |
536 | 552 |
537 ngx_queue_remove(&qs->queue); | 553 ngx_queue_remove(&qs->queue); |
538 | 554 |
539 c->listening->handler(c); | 555 c->listening->handler(c); |
540 } | 556 } |
702 sc->read->handler = ngx_quic_empty_handler; | 718 sc->read->handler = ngx_quic_empty_handler; |
703 sc->write->handler = ngx_quic_empty_handler; | 719 sc->write->handler = ngx_quic_empty_handler; |
704 | 720 |
705 log->connection = sc->number; | 721 log->connection = sc->number; |
706 | 722 |
707 if ((id & NGX_QUIC_STREAM_UNIDIRECTIONAL) == 0 | |
708 || (id & NGX_QUIC_STREAM_SERVER_INITIATED)) | |
709 { | |
710 sc->write->active = 1; | |
711 sc->write->ready = 1; | |
712 } | |
713 | |
714 if ((id & NGX_QUIC_STREAM_UNIDIRECTIONAL) == 0 | |
715 || (id & NGX_QUIC_STREAM_SERVER_INITIATED) == 0) | |
716 { | |
717 sc->read->active = 1; | |
718 } | |
719 | |
720 if (id & NGX_QUIC_STREAM_UNIDIRECTIONAL) { | 723 if (id & NGX_QUIC_STREAM_UNIDIRECTIONAL) { |
721 if (id & NGX_QUIC_STREAM_SERVER_INITIATED) { | 724 if (id & NGX_QUIC_STREAM_SERVER_INITIATED) { |
722 qs->send_max_data = qc->ctp.initial_max_stream_data_uni; | 725 qs->send_max_data = qc->ctp.initial_max_stream_data_uni; |
723 qs->recv_state = NGX_QUIC_STREAM_RECV_DATA_READ; | 726 qs->recv_state = NGX_QUIC_STREAM_RECV_DATA_READ; |
724 qs->send_state = NGX_QUIC_STREAM_SEND_READY; | 727 qs->send_state = NGX_QUIC_STREAM_SEND_READY; |