| line |
true |
false |
branch |
|
34
|
42 |
42 |
for (i = 0; i < num_protos; i++) { |
|
35
|
0 |
42 |
for (j = 0; j < params->negotiated_protocols.count; j++) { |
|
36
|
0 |
0 |
if (params->negotiated_protocols.list[j].len == protos[i].len && |
|
38
|
0 |
0 |
protos[i].len) == 0) { |
|
108
|
3 |
70 |
if (ret != 0) { |
|
117
|
2 |
68 |
if (!fp) { |
|
125
|
0 |
68 |
if (!pkey) { |
|
132
|
0 |
68 |
if (ptls_openssl_init_sign_certificate(sign_cert, pkey) != 0) { |
|
142
|
0 |
68 |
if (h2) |
|
161
|
0 |
72 |
if (!ctx) return; |
|
162
|
72 |
0 |
if (ctx->certificates.list) { |
|
164
|
69 |
72 |
for (i = 0; i < ctx->certificates.count; i++) |
|
169
|
67 |
5 |
if (ctx->sign_certificate) { |
|
203
|
67 |
55 |
if (--ref->refcount <= 0) { |
|
216
|
0 |
59 |
if (unlikely(!c->tls)) { |
|
233
|
54 |
526 |
if (c->tls) { |
|
237
|
54 |
526 |
if (c->tls_ctx_ref) { |
|
242
|
0 |
580 |
if (c->tls_rbuf) { |
|
247
|
3 |
577 |
if (c->tls_tunnel) { |
|
251
|
3 |
0 |
if (c->tls_tunnel_sv0 >= 0) { |
|
255
|
0 |
3 |
if (c->tls_tunnel_sv1 >= 0) { |
|
259
|
0 |
3 |
if (c->tls_tunnel_wbuf) { |
|
275
|
0 |
114 |
if (c->tls_wbuf.off == 0) |
|
279
|
0 |
114 |
if (written < 0) { |
|
280
|
0 |
0 |
if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) { |
|
|
0 |
0 |
if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) { |
|
|
0 |
0 |
if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) { |
|
287
|
0 |
114 |
if ((size_t)written < c->tls_wbuf.off) { |
|
323
|
0 |
6 |
if (c->tls_tunnel_sv0 < 0) return -1; |
|
326
|
6 |
0 |
if (nw == (ssize_t)len) |
|
329
|
0 |
0 |
if (nw < 0) { |
|
330
|
0 |
0 |
if (errno != EAGAIN && errno != EWOULDBLOCK && errno != EINTR) |
|
|
0 |
0 |
if (errno != EAGAIN && errno != EWOULDBLOCK && errno != EINTR) |
|
|
0 |
0 |
if (errno != EAGAIN && errno != EWOULDBLOCK && errno != EINTR) |
|
336
|
0 |
0 |
if (!c->tls_tunnel_wbuf) { |
|
341
|
0 |
0 |
if (c->tls_tunnel_wbuf_pos > 0) { |
|
343
|
0 |
0 |
if (remain > 0) |
|
351
|
0 |
0 |
if (SvCUR(c->tls_tunnel_wbuf) + remaining > FEER_TUNNEL_MAX_WBUF) { |
|
357
|
0 |
0 |
if (!ev_is_active(&c->tls_tunnel_write_w)) |
|
375
|
0 |
9 |
if (nread == 0) { |
|
381
|
0 |
9 |
if (nread < 0) { |
|
382
|
0 |
0 |
if (errno == EAGAIN || errno == EWOULDBLOCK) |
|
|
0 |
0 |
if (errno == EAGAIN || errno == EWOULDBLOCK) |
|
390
|
0 |
9 |
if (feer_tls_send(c, buf, nread) != 0) { |
|
398
|
0 |
9 |
if (flush_ret == -2) { |
|
403
|
0 |
9 |
if (c->tls_wbuf.off > 0) |
|
417
|
0 |
0 |
if (!c->tls_tunnel_wbuf || |
|
418
|
0 |
0 |
SvCUR(c->tls_tunnel_wbuf) <= c->tls_tunnel_wbuf_pos) { |
|
420
|
0 |
0 |
if (c->tls_tunnel_wbuf) { |
|
431
|
0 |
0 |
if (nw < 0) { |
|
432
|
0 |
0 |
if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) |
|
|
0 |
0 |
if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) |
|
|
0 |
0 |
if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) |
|
441
|
0 |
0 |
if (c->tls_tunnel_wbuf_pos >= SvCUR(c->tls_tunnel_wbuf)) { |
|
454
|
0 |
3 |
if (c->tls_tunnel) return; |
|
457
|
0 |
3 |
if (feer_socketpair_nb(sv) < 0) { |
|
478
|
3 |
0 |
if (c->rbuf && SvOK(c->rbuf) && SvCUR(c->rbuf) > 0) { |
|
|
3 |
0 |
if (c->rbuf && SvOK(c->rbuf) && SvCUR(c->rbuf) > 0) { |
|
|
0 |
3 |
if (c->rbuf && SvOK(c->rbuf) && SvCUR(c->rbuf) > 0) { |
|
480
|
0 |
0 |
if (tls_tunnel_write_or_buffer(c, SvPVX(c->rbuf), SvCUR(c->rbuf)) < 0) { |
|
503
|
0 |
50 |
if (!c->tls_rbuf || c->tls_rbuf_len == 0) return -1; |
|
|
0 |
0 |
if (!c->tls_rbuf || c->tls_rbuf_len == 0) return -1; |
|
513
|
0 |
0 |
if (ret == 0 && consumed < saved_len) { |
|
|
0 |
0 |
if (ret == 0 && consumed < saved_len) { |
|
521
|
0 |
0 |
if (ret != 0) { |
|
525
|
0 |
0 |
if (decbuf->off == 0) { |
|
574
|
1 |
308 |
if (unlikely(c->pipelined)) goto tls_pipelined; |
|
576
|
0 |
308 |
if (unlikely(!c->tls)) { |
|
587
|
3 |
305 |
if (nread == 0) { |
|
596
|
0 |
305 |
if (nread < 0) { |
|
597
|
0 |
0 |
if (errno == EAGAIN || errno == EWOULDBLOCK) |
|
|
0 |
0 |
if (errno == EAGAIN || errno == EWOULDBLOCK) |
|
610
|
152 |
153 |
if (unlikely(c->receiving == RECEIVE_PROXY_HEADER)) { |
|
611
|
23 |
129 |
if (!c->rbuf) { |
|
617
|
4 |
148 |
if (ret == -1) { |
|
622
|
129 |
19 |
if (ret == -2) goto tls_read_cleanup; /* need more data */ |
|
628
|
0 |
19 |
feer_clear_remote_cache(c); |
|
|
0 |
19 |
feer_clear_remote_cache(c); |
|
632
|
0 |
19 |
if (remaining > 0) { |
|
643
|
19 |
0 |
if (remaining == 0) |
|
656
|
0 |
153 |
if (c->tls_rbuf_len > 0) { |
|
657
|
0 |
0 |
if (nread > 0) { |
|
674
|
55 |
98 |
if (!c->tls_handshake_done) { |
|
682
|
46 |
9 |
if (hsbuf.off > 0) { |
|
683
|
0 |
46 |
if (tls_wbuf_append(&c->tls_wbuf, hsbuf.base, hsbuf.off) != 0) { |
|
686
|
0 |
0 |
if (merged) Safefree(merged); |
|
691
|
0 |
46 |
if (flush_ret == -2) { |
|
694
|
0 |
0 |
if (merged) Safefree(merged); |
|
698
|
46 |
0 |
if (flush_ret == -1 || c->tls_wbuf.off > 0) { |
|
|
0 |
46 |
if (flush_ret == -1 || c->tls_wbuf.off > 0) { |
|
705
|
42 |
13 |
if (ret == 0) { |
|
712
|
0 |
42 |
if (proto && strlen(proto) == 2 && memcmp(proto, "h2", 2) == 0) { |
|
|
0 |
0 |
if (proto && strlen(proto) == 2 && memcmp(proto, "h2", 2) == 0) { |
|
|
0 |
0 |
if (proto && strlen(proto) == 2 && memcmp(proto, "h2", 2) == 0) { |
|
723
|
0 |
42 |
if (consumed < inlen) { |
|
764
|
0 |
0 |
if (dec_ret == 0 && dec_consumed < remaining) { |
|
|
0 |
0 |
if (dec_ret == 0 && dec_consumed < remaining) { |
|
770
|
0 |
0 |
if (dec_ret == 0 && decbuf.off > 0) { |
|
|
0 |
0 |
if (dec_ret == 0 && decbuf.off > 0) { |
|
772
|
0 |
0 |
if (!c->rbuf) { |
|
780
|
0 |
0 |
if (parse_ret == -1) { |
|
783
|
0 |
0 |
if (merged) Safefree(merged); |
|
786
|
0 |
0 |
if (parse_ret > 0) { |
|
787
|
0 |
0 |
if (!process_request_headers(c, parse_ret)) |
|
795
|
9 |
4 |
} else if (ret == PTLS_ERROR_IN_PROGRESS) { |
|
799
|
0 |
9 |
if (consumed < inlen) { |
|
811
|
0 |
55 |
if (merged) Safefree(merged); |
|
823
|
98 |
0 |
if (ret == 0 && consumed < inlen) { |
|
|
0 |
98 |
if (ret == 0 && consumed < inlen) { |
|
830
|
0 |
98 |
if (merged) Safefree(merged); |
|
832
|
0 |
98 |
if (ret != 0) { |
|
844
|
42 |
56 |
if (decbuf.off == 0) { |
|
867
|
6 |
50 |
if (c->tls_tunnel) { |
|
868
|
0 |
6 |
if (tls_tunnel_write_or_buffer(c, (const char *)decbuf.base, decbuf.off) < 0) { |
|
881
|
42 |
8 |
if (!c->rbuf) { |
|
891
|
0 |
50 |
while ((drain_rv = feer_tls_drain_one_record(c, &db)) >= 0) { |
|
892
|
0 |
0 |
if (drain_rv == 1) continue; /* non-data TLS record */ |
|
907
|
7 |
44 |
if (c->receiving == RECEIVE_WAIT) |
|
910
|
49 |
2 |
if (likely(c->receiving <= RECEIVE_HEADERS)) { |
|
912
|
0 |
49 |
if (parse_ret == -1) { |
|
917
|
0 |
49 |
if (parse_ret == -2) { |
|
922
|
47 |
2 |
if (!process_request_headers(c, parse_ret)) |
|
925
|
2 |
0 |
else if (likely(c->receiving == RECEIVE_BODY)) { |
|
927
|
2 |
0 |
if (c->received_cl >= c->expected_cl) { |
|
932
|
0 |
0 |
else if (c->receiving == RECEIVE_CHUNKED) { |
|
934
|
0 |
0 |
if (ret == -1) { |
|
938
|
0 |
0 |
else if (ret == 0) { |
|
944
|
0 |
0 |
else if (c->receiving == RECEIVE_STREAMING) { |
|
946
|
0 |
0 |
if (c->poll_read_cb) { |
|
949
|
0 |
0 |
if (c->receiving >= RECEIVE_SHUTDOWN) { |
|
953
|
0 |
0 |
if (c->expected_cl > 0 && c->received_cl >= c->expected_cl) |
|
|
0 |
0 |
if (c->expected_cl > 0 && c->received_cl >= c->expected_cl) |
|
978
|
0 |
56 |
if (unlikely(!c->tls)) { |
|
985
|
0 |
56 |
if (c->tls_wbuf.off > 0) { |
|
987
|
0 |
0 |
if (flush_ret == -1) goto tls_write_cleanup; /* EAGAIN, keep write watcher active */ |
|
988
|
0 |
0 |
if (flush_ret == -2) goto tls_write_error; |
|
990
|
0 |
0 |
if (c->tls_wbuf.off > 0) goto tls_write_cleanup; |
|
1015
|
56 |
0 |
if (c->wbuf_rinq && c->cached_wbuf_low_water > 0 |
|
|
1 |
55 |
if (c->wbuf_rinq && c->cached_wbuf_low_water > 0 |
|
1016
|
1 |
0 |
&& c->wbuf_len <= c->cached_wbuf_low_water |
|
1017
|
1 |
0 |
&& c->responding == RESPOND_STREAMING && c->poll_write_cb) { |
|
|
1 |
0 |
&& c->responding == RESPOND_STREAMING && c->poll_write_cb) { |
|
1018
|
0 |
1 |
if (c->poll_write_cb_is_io_handle) |
|
1025
|
56 |
0 |
if (c->wbuf_rinq) { |
|
1027
|
59 |
56 |
while ((m = (struct iomatrix *)rinq_shift(&c->wbuf_rinq)) != NULL) { |
|
1029
|
605 |
59 |
for (i = 0; i < m->count; i++) { |
|
1030
|
0 |
605 |
if (m->iov[i].iov_len == 0) continue; |
|
1038
|
0 |
605 |
if (ret != 0) { |
|
1042
|
0 |
0 |
for (j = 0; j < m->count; j++) { |
|
1043
|
0 |
0 |
if (m->sv[j]) SvREFCNT_dec(m->sv[j]); |
|
1045
|
0 |
0 |
IOMATRIX_FREE(m); |
|
1048
|
605 |
0 |
if (encbuf.off > 0) { |
|
1049
|
0 |
605 |
if (tls_wbuf_append(&c->tls_wbuf, encbuf.base, encbuf.off) != 0) { |
|
1053
|
0 |
0 |
for (j = 0; j < m->count; j++) { |
|
1054
|
0 |
0 |
if (m->sv[j]) SvREFCNT_dec(m->sv[j]); |
|
1056
|
0 |
0 |
IOMATRIX_FREE(m); |
|
1064
|
605 |
59 |
for (i = 0; i < m->count; i++) { |
|
1065
|
289 |
316 |
if (m->sv[i]) SvREFCNT_dec(m->sv[i]); |
|
1067
|
59 |
0 |
IOMATRIX_FREE(m); |
|
1070
|
4 |
55 |
if (c->cached_wbuf_low_water > 0 |
|
1071
|
4 |
0 |
&& c->wbuf_len <= c->cached_wbuf_low_water |
|
1072
|
3 |
1 |
&& c->responding == RESPOND_STREAMING && c->poll_write_cb) { |
|
|
3 |
0 |
&& c->responding == RESPOND_STREAMING && c->poll_write_cb) { |
|
1073
|
0 |
3 |
if (c->poll_write_cb_is_io_handle) |
|
1083
|
0 |
56 |
if (flush_ret == -1) goto tls_write_cleanup; /* EAGAIN */ |
|
1084
|
0 |
56 |
if (flush_ret == -2) goto tls_write_error; |
|
1085
|
56 |
0 |
if (flush_ret > 0) restart_write_timer(c); |
|
1089
|
1 |
55 |
if (c->sendfile_fd >= 0 && c->sendfile_remain > 0) { |
|
|
0 |
1 |
if (c->sendfile_fd >= 0 && c->sendfile_remain > 0) { |
|
1092
|
0 |
1 |
if (to_read > sizeof(filebuf)) to_read = sizeof(filebuf); |
|
1095
|
0 |
1 |
if (file_nread <= 0) { |
|
1096
|
0 |
0 |
if (file_nread < 0) |
|
1098
|
0 |
0 |
CLOSE_SENDFILE_FD(c); |
|
|
0 |
0 |
CLOSE_SENDFILE_FD(c); |
|
1107
|
0 |
1 |
if (ret != 0) { |
|
1110
|
0 |
0 |
CLOSE_SENDFILE_FD(c); |
|
|
0 |
0 |
CLOSE_SENDFILE_FD(c); |
|
1115
|
1 |
0 |
if (encbuf.off > 0) { |
|
1116
|
0 |
1 |
if (tls_wbuf_append(&c->tls_wbuf, encbuf.base, encbuf.off) != 0) { |
|
1119
|
0 |
0 |
CLOSE_SENDFILE_FD(c); |
|
|
0 |
0 |
CLOSE_SENDFILE_FD(c); |
|
1128
|
1 |
0 |
if (c->sendfile_remain == 0) |
|
1129
|
1 |
0 |
CLOSE_SENDFILE_FD(c); |
|
|
0 |
1 |
CLOSE_SENDFILE_FD(c); |
|
1134
|
0 |
1 |
if (sf_flush_ret == -1) goto tls_write_cleanup; /* EAGAIN */ |
|
1135
|
0 |
1 |
if (sf_flush_ret == -2) goto tls_write_error; |
|
1137
|
1 |
0 |
if (c->sendfile_remain > 0 || c->tls_wbuf.off > 0) |
|
|
0 |
1 |
if (c->sendfile_remain > 0 || c->tls_wbuf.off > 0) |
|
1143
|
0 |
56 |
if ((!c->wbuf_rinq || (c->cached_wbuf_low_water > 0 |
|
|
0 |
0 |
if ((!c->wbuf_rinq || (c->cached_wbuf_low_water > 0 |
|
1144
|
0 |
0 |
&& c->wbuf_len <= c->cached_wbuf_low_water)) |
|
1145
|
56 |
0 |
&& c->sendfile_fd < 0 && c->tls_wbuf.off == 0) { |
|
|
56 |
0 |
&& c->sendfile_fd < 0 && c->tls_wbuf.off == 0) { |
|
1146
|
10 |
46 |
if (c->responding == RESPOND_SHUTDOWN || c->responding == RESPOND_NORMAL) { |
|
|
0 |
10 |
if (c->responding == RESPOND_SHUTDOWN || c->responding == RESPOND_NORMAL) { |
|
1148
|
10 |
0 |
} else if (c->responding == RESPOND_STREAMING && c->poll_write_cb) { |
|
|
10 |
0 |
} else if (c->responding == RESPOND_STREAMING && c->poll_write_cb) { |
|
1149
|
0 |
10 |
if (c->poll_write_cb_is_io_handle) |
|
1153
|
0 |
0 |
} else if (c->responding == RESPOND_STREAMING) { |
|
1176
|
11 |
0 |
if (!c->tls || len == 0) return 0; |
|
|
0 |
11 |
if (!c->tls || len == 0) return 0; |
|
1181
|
0 |
11 |
if (ret != 0) { |
|
1186
|
11 |
0 |
if (encbuf.off > 0) { |
|
1187
|
0 |
11 |
if (tls_wbuf_append(&c->tls_wbuf, encbuf.base, encbuf.off) != 0) { |