comparison src/event/ngx_event_quic.c @ 7996:d2f716e668e8 quic

Fixed format specifiers.
author Sergey Kandaurov <pluknet@nginx.com>
date Mon, 20 Jul 2020 15:19:03 +0300
parents 031918df51c0
children b250b515e5b6
comparison
equal deleted inserted replaced
7995:031918df51c0 7996:d2f716e668e8
643 return rc; 643 return rc;
644 } 644 }
645 645
646 if (!ngx_quic_pkt_in(pkt->flags)) { 646 if (!ngx_quic_pkt_in(pkt->flags)) {
647 ngx_log_error(NGX_LOG_INFO, c->log, 0, 647 ngx_log_error(NGX_LOG_INFO, c->log, 0,
648 "quic invalid initial packet: 0x%xi", pkt->flags); 648 "quic invalid initial packet: 0x%xd", pkt->flags);
649 return NGX_ERROR; 649 return NGX_ERROR;
650 } 650 }
651 651
652 if (ngx_quic_parse_initial_header(pkt) != NGX_OK) { 652 if (ngx_quic_parse_initial_header(pkt) != NGX_OK) {
653 return NGX_ERROR; 653 return NGX_ERROR;
1612 return NGX_OK; 1612 return NGX_OK;
1613 } 1613 }
1614 1614
1615 if (!ngx_quic_pkt_in(pkt->flags)) { 1615 if (!ngx_quic_pkt_in(pkt->flags)) {
1616 ngx_log_error(NGX_LOG_INFO, c->log, 0, 1616 ngx_log_error(NGX_LOG_INFO, c->log, 0,
1617 "quic invalid initial packet: 0x%xi", pkt->flags); 1617 "quic invalid initial packet: 0x%xd", pkt->flags);
1618 return NGX_ERROR; 1618 return NGX_ERROR;
1619 } 1619 }
1620 1620
1621 if (ngx_quic_parse_initial_header(pkt) != NGX_OK) { 1621 if (ngx_quic_parse_initial_header(pkt) != NGX_OK) {
1622 return NGX_ERROR; 1622 return NGX_ERROR;
2155 2155
2156 frame->type = NGX_QUIC_FT_ACK; 2156 frame->type = NGX_QUIC_FT_ACK;
2157 frame->u.ack.largest = pkt->pn; 2157 frame->u.ack.largest = pkt->pn;
2158 frame->u.ack.delay = ngx_quic_ack_delay(c, &pkt->received, frame->level); 2158 frame->u.ack.delay = ngx_quic_ack_delay(c, &pkt->received, frame->level);
2159 2159
2160 ngx_sprintf(frame->info, "ACK for PN=%d from frame handler level=%d", 2160 ngx_sprintf(frame->info, "ACK for PN=%uL from frame handler level=%d",
2161 pkt->pn, frame->level); 2161 pkt->pn, frame->level);
2162 ngx_quic_queue_frame(c->quic, frame); 2162 ngx_quic_queue_frame(c->quic, frame);
2163 2163
2164 return NGX_OK; 2164 return NGX_OK;
2165 } 2165 }
2550 2550
2551 f = &frame->u.ord; 2551 f = &frame->u.ord;
2552 2552
2553 if (f->offset > fs->received) { 2553 if (f->offset > fs->received) {
2554 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, 2554 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,
2555 "quic out-of-order frame: expecting %ui got %ui", 2555 "quic out-of-order frame: expecting %uL got %uL",
2556 fs->received, f->offset); 2556 fs->received, f->offset);
2557 2557
2558 return ngx_quic_buffer_frame(c, fs, frame); 2558 return ngx_quic_buffer_frame(c, fs, frame);
2559 } 2559 }
2560 2560
2767 2767
2768 2768
2769 static ngx_int_t 2769 static ngx_int_t
2770 ngx_quic_crypto_input(ngx_connection_t *c, ngx_quic_frame_t *frame, void *data) 2770 ngx_quic_crypto_input(ngx_connection_t *c, ngx_quic_frame_t *frame, void *data)
2771 { 2771 {
2772 int sslerr; 2772 int n, sslerr;
2773 ssize_t n;
2774 ngx_ssl_conn_t *ssl_conn; 2773 ngx_ssl_conn_t *ssl_conn;
2775 ngx_quic_send_ctx_t *ctx; 2774 ngx_quic_send_ctx_t *ctx;
2776 ngx_quic_crypto_frame_t *f; 2775 ngx_quic_crypto_frame_t *f;
2777 2776
2778 f = &frame->u.crypto; 2777 f = &frame->u.crypto;
2887 2886
2888 sn = ngx_quic_find_stream(&qc->streams.tree, f->stream_id); 2887 sn = ngx_quic_find_stream(&qc->streams.tree, f->stream_id);
2889 2888
2890 if (sn == NULL) { 2889 if (sn == NULL) {
2891 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, 2890 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0,
2892 "quic stream id 0x%xi is new", f->stream_id); 2891 "quic stream id 0x%xL is new", f->stream_id);
2893 2892
2894 if (f->stream_id & NGX_QUIC_STREAM_SERVER_INITIATED) { 2893 if (f->stream_id & NGX_QUIC_STREAM_SERVER_INITIATED) {
2895 qc->error = NGX_QUIC_ERR_STREAM_STATE_ERROR; 2894 qc->error = NGX_QUIC_ERR_STREAM_STATE_ERROR;
2896 return NGX_ERROR; 2895 return NGX_ERROR;
2897 } 2896 }
3261 3260
3262 sn = ngx_quic_find_stream(&qc->streams.tree, f->id); 3261 sn = ngx_quic_find_stream(&qc->streams.tree, f->id);
3263 3262
3264 if (sn == NULL) { 3263 if (sn == NULL) {
3265 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, 3264 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0,
3266 "quic stream id 0x%xi is new", f->id); 3265 "quic stream id 0x%xL is new", f->id);
3267 3266
3268 if (f->id & NGX_QUIC_STREAM_SERVER_INITIATED) { 3267 if (f->id & NGX_QUIC_STREAM_SERVER_INITIATED) {
3269 qc->error = NGX_QUIC_ERR_STREAM_STATE_ERROR; 3268 qc->error = NGX_QUIC_ERR_STREAM_STATE_ERROR;
3270 return NGX_ERROR; 3269 return NGX_ERROR;
3271 } 3270 }
3949 pc = qs->parent; 3948 pc = qs->parent;
3950 qc = pc->quic; 3949 qc = pc->quic;
3951 rev = c->read; 3950 rev = c->read;
3952 3951
3953 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0, 3952 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0,
3954 "quic stream id 0x%xi recv: eof:%d, avail:%z", 3953 "quic stream id 0x%xL recv: eof:%d, avail:%z",
3955 qs->id, rev->pending_eof, b->last - b->pos); 3954 qs->id, rev->pending_eof, b->last - b->pos);
3956 3955
3957 if (b->pos == b->last) { 3956 if (b->pos == b->last) {
3958 rev->ready = 0; 3957 rev->ready = 0;
3959 3958
3961 rev->eof = 1; 3960 rev->eof = 1;
3962 return 0; 3961 return 0;
3963 } 3962 }
3964 3963
3965 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, 3964 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0,
3966 "quic stream id 0x%xi recv() not ready", qs->id); 3965 "quic stream id 0x%xL recv() not ready", qs->id);
3967 return NGX_AGAIN; 3966 return NGX_AGAIN;
3968 } 3967 }
3969 3968
3970 len = ngx_min(b->last - b->pos, (ssize_t) size); 3969 len = ngx_min(b->last - b->pos, (ssize_t) size);
3971 3970
3979 b->last = b->start; 3978 b->last = b->start;
3980 rev->ready = rev->pending_eof; 3979 rev->ready = rev->pending_eof;
3981 } 3980 }
3982 3981
3983 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0, 3982 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0,
3984 "quic stream id 0x%xi recv: %z of %uz", qs->id, len, size); 3983 "quic stream id 0x%xL recv: %z of %uz", qs->id, len, size);
3985 3984
3986 if (!rev->pending_eof) { 3985 if (!rev->pending_eof) {
3987 frame = ngx_quic_alloc_frame(pc, 0); 3986 frame = ngx_quic_alloc_frame(pc, 0);
3988 if (frame == NULL) { 3987 if (frame == NULL) {
3989 return NGX_ERROR; 3988 return NGX_ERROR;
4021 (int) frame->u.max_data.max_data, frame->level); 4020 (int) frame->u.max_data.max_data, frame->level);
4022 4021
4023 ngx_quic_queue_frame(pc->quic, frame); 4022 ngx_quic_queue_frame(pc->quic, frame);
4024 4023
4025 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, 4024 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,
4026 "quic stream id 0x%xi recv: increased max data: %ui", 4025 "quic stream id 0x%xL recv: increased max data: %uL",
4027 qs->id, qc->streams.recv_max_data); 4026 qs->id, qc->streams.recv_max_data);
4028 } 4027 }
4029 4028
4030 return len; 4029 return len;
4031 } 4030 }
4049 if (qc->closing) { 4048 if (qc->closing) {
4050 return NGX_ERROR; 4049 return NGX_ERROR;
4051 } 4050 }
4052 4051
4053 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, 4052 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,
4054 "quic stream id 0x%xi send: %uz", qs->id, size); 4053 "quic stream id 0x%xL send: %uz", qs->id, size);
4055 4054
4056 /* 4055 /*
4057 * we need to fit at least 1 frame into a packet, thus account head/tail; 4056 * we need to fit at least 1 frame into a packet, thus account head/tail;
4058 * 25 = 1 + 8x3 is max header for STREAM frame, with 1 byte for frame type 4057 * 25 = 1 + 8x3 is max header for STREAM frame, with 1 byte for frame type
4059 */ 4058 */
4125 c->sent += fsize; 4124 c->sent += fsize;
4126 qc->streams.sent += fsize; 4125 qc->streams.sent += fsize;
4127 p += fsize; 4126 p += fsize;
4128 n += fsize; 4127 n += fsize;
4129 4128
4130 ngx_sprintf(frame->info, "stream 0x%xi len=%ui level=%d", 4129 ngx_sprintf(frame->info, "stream 0x%xL len=%ui level=%d",
4131 qs->id, fsize, frame->level); 4130 qs->id, fsize, frame->level);
4132 4131
4133 ngx_quic_queue_frame(qc, frame); 4132 ngx_quic_queue_frame(qc, frame);
4134 } 4133 }
4135 4134
4162 qs = c->qs; 4161 qs = c->qs;
4163 pc = qs->parent; 4162 pc = qs->parent;
4164 qc = pc->quic; 4163 qc = pc->quic;
4165 4164
4166 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, 4165 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0,
4167 "quic stream id 0x%xi cleanup", qs->id); 4166 "quic stream id 0x%xL cleanup", qs->id);
4168 4167
4169 ngx_rbtree_delete(&qc->streams.tree, &qs->node); 4168 ngx_rbtree_delete(&qc->streams.tree, &qs->node);
4170 ngx_quic_free_frames(pc, &qs->fs.frames); 4169 ngx_quic_free_frames(pc, &qs->fs.frames);
4171 4170
4172 if (qc->closing) { 4171 if (qc->closing) {
4179 /* do not send fin for client unidirectional streams */ 4178 /* do not send fin for client unidirectional streams */
4180 return; 4179 return;
4181 } 4180 }
4182 4181
4183 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, 4182 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0,
4184 "quic stream id 0x%xi send fin", qs->id); 4183 "quic stream id 0x%xL send fin", qs->id);
4185 4184
4186 frame = ngx_quic_alloc_frame(pc, 0); 4185 frame = ngx_quic_alloc_frame(pc, 0);
4187 if (frame == NULL) { 4186 if (frame == NULL) {
4188 return; 4187 return;
4189 } 4188 }
4198 frame->u.stream.stream_id = qs->id; 4197 frame->u.stream.stream_id = qs->id;
4199 frame->u.stream.offset = c->sent; 4198 frame->u.stream.offset = c->sent;
4200 frame->u.stream.length = 0; 4199 frame->u.stream.length = 0;
4201 frame->u.stream.data = NULL; 4200 frame->u.stream.data = NULL;
4202 4201
4203 ngx_sprintf(frame->info, "stream 0x%xi fin=1 level=%d", 4202 ngx_sprintf(frame->info, "stream 0x%xL fin=1 level=%d",
4204 qs->id, frame->level); 4203 qs->id, frame->level);
4205 4204
4206 ngx_quic_queue_frame(qc, frame); 4205 ngx_quic_queue_frame(qc, frame);
4207 4206
4208 (void) ngx_quic_output(pc); 4207 (void) ngx_quic_output(pc);