| line |
true |
false |
branch |
|
7
|
0 |
185 |
if (elt == NULL) return NULL; |
|
9
|
4 |
181 |
if (unlikely(SvMAGICAL(sv))) sv = sv_2mortal(newSVsv(sv)); |
|
10
|
3 |
182 |
if (unlikely(!SvOK(sv))) return NULL; |
|
12
|
6 |
176 |
if (unlikely(SvROK(sv))) sv = SvRV(sv); |
|
23
|
785 |
241 |
if (!c->wbuf_rinq) { |
|
32
|
0 |
241 |
if (m->count >= FEERSUM_IOMATRIX_SIZE) { |
|
37
|
785 |
241 |
if (add_iomatrix) { |
|
39
|
692 |
93 |
IOMATRIX_ALLOC(m); |
|
56
|
1 |
335 |
if (unlikely(SvMAGICAL(sv))) { |
|
59
|
0 |
335 |
else if (unlikely(SvPADTMP(sv))) { |
|
64
|
0 |
0 |
if (SvFLAGS(sv) == (SVs_PADTMP|SVf_POK|SVp_POK)) { |
|
74
|
0 |
0 |
(void)SvOK_off(sv); |
|
131
|
19 |
40 |
if (!c->use_chunked) return; // nothing required unless chunked encoding |
|
151
|
0 |
59 |
if (unlikely(len == 0)) return; /* skip: "0\r\n\r\n" is the terminal chunk */ |
|
253
|
656 |
0 |
if (likely(is_tcp)) { |
|
254
|
0 |
656 |
if (unlikely(setsockopt(fd, SOL_TCP, TCP_NODELAY, &flags, sizeof(int)))) |
|
272
|
6 |
0 |
if (likely(c->cached_is_tcp)) { |
|
288
|
0 |
8 |
PUSHMARK(SP); |
|
293
|
8 |
0 |
if (SvTRUE(ERRSV)) |
|
|
1 |
7 |
if (SvTRUE(ERRSV)) |
|
294
|
1 |
0 |
sv_setsv(ERRSV, &PL_sv_undef); |
|
296
|
0 |
8 |
FREETMPS; |
|
303
|
607 |
656 |
if (unlikely(c->fd < 0)) |
|
315
|
0 |
656 |
CLOSE_SENDFILE_FD(c); |
|
|
0 |
0 |
CLOSE_SENDFILE_FD(c); |
|
319
|
68 |
588 |
if (c->tls && c->tls_handshake_done) { |
|
|
51 |
17 |
if (c->tls && c->tls_handshake_done) { |
|
323
|
51 |
0 |
if (closebuf.off > 0) { |
|
335
|
0 |
656 |
if (unlikely(close(c->fd) < 0)) |
|
346
|
656 |
0 |
SvUPGRADE(self, SVt_PVMG); // ensures sv_bless doesn't reallocate |
|
347
|
656 |
0 |
SvGROW(self, sizeof(struct feer_conn)); |
|
|
656 |
0 |
SvGROW(self, sizeof(struct feer_conn)); |
|
374
|
159 |
497 |
c->receiving = srvr->use_proxy_protocol ? RECEIVE_PROXY_HEADER : RECEIVE_HEADERS; |
|
378
|
68 |
588 |
if (lsnr->tls_ctx_ref) { |
|
428
|
0 |
1530 |
if (unlikely(!sv_isa(rv,"Feersum::Connection"))) |
|
444
|
0 |
670 |
if (unlikely(!SvROK(rv))) croak("Expected a reference"); |
|
447
|
670 |
0 |
if (likely( |
|
|
428 |
242 |
if (likely( |
|
|
428 |
0 |
if (likely( |
|
|
670 |
0 |
if (likely( |
|
453
|
87 |
583 |
if (uv == 0) { |
|
454
|
15 |
72 |
if (can_croak) croak("Operation not allowed: Handle is closed."); |
|
460
|
0 |
0 |
if (can_croak) |
|
471
|
78 |
310 |
sv_bless(sv, is_writer ? feer_conn_writer_stash : feer_conn_reader_stash); |
|
491
|
3424 |
214 |
for (int i = 0; i < FEER_MAX_LISTENERS; i++) { |
|
504
|
214 |
0 |
SvUPGRADE(self, SVt_PVMG); |
|
505
|
214 |
0 |
SvGROW(self, sizeof(struct feer_server)); |
|
|
214 |
0 |
SvGROW(self, sizeof(struct feer_server)); |
|
526
|
27461 |
33 |
if (sv_isa(rv, "Feersum")) { |
|
530
|
33 |
0 |
if (SvPOK(rv) && strEQ(SvPV_nolen(rv), "Feersum")) { |
|
|
33 |
0 |
if (SvPOK(rv) && strEQ(SvPV_nolen(rv), "Feersum")) { |
|
531
|
0 |
33 |
if (unlikely(!default_server)) |
|
549
|
12 |
146 |
if (unlikely(ev_is_active(&c->read_ev_io))) |
|
558
|
880 |
137 |
if (unlikely(!ev_is_active(&c->read_ev_io))) |
|
567
|
121 |
21 |
if (likely(!ev_is_active(&c->read_ev_timer))) { |
|
577
|
909 |
117 |
if (unlikely(!ev_is_active(&c->read_ev_timer))) |
|
587
|
121 |
526 |
if (unlikely(ev_is_active(&c->write_ev_io))) |
|
596
|
290 |
526 |
if (unlikely(!ev_is_active(&c->write_ev_io))) |
|
605
|
781 |
1 |
if (c->cached_write_timeout <= 0.0) return; |
|
606
|
1 |
0 |
if (likely(!ev_is_active(&c->write_ev_timer))) { |
|
616
|
836 |
1 |
if (unlikely(!ev_is_active(&c->write_ev_timer))) |
|
625
|
994 |
783 |
if (unlikely(!ev_is_active(&c->header_ev_timer))) |
|
635
|
0 |
145 |
if (timeout <= 0.0) return; |
|
663
|
34 |
1721 |
if (c->idle_rinq_node) { |
|
672
|
0 |
36 |
if (c->idle_rinq_node) return; // already idle |
|
681
|
9 |
2 |
if (!srvr->idle_keepalive_rinq) return 0; |
|
684
|
0 |
2 |
if (unlikely(!c)) return 0; |
|
706
|
548 |
385 |
while (server->request_ready_rinq) { |
|
709
|
0 |
548 |
if (unlikely(!c)) break; |
|
713
|
520 |
28 |
if (likely(c->wbuf_rinq)) { |
|
735
|
0 |
160 |
if (unlikely(revents & EV_ERROR)) { |
|
741
|
158 |
2 |
if (!srvr->shutting_down) { |
|
742
|
245 |
158 |
for (int i = 0; i < srvr->n_listeners; i++) { |
|
744
|
166 |
79 |
if (!ev_is_active(&lsnr->accept_w) && !lsnr->pause_flags) { |
|
|
166 |
0 |
if (!ev_is_active(&lsnr->accept_w) && !lsnr->pause_flags) { |
|
757
|
0 |
5095 |
if (unlikely(revents & EV_ERROR)) { |
|
764
|
385 |
4710 |
if (server->request_ready_rinq) |
|
774
|
0 |
382 |
if (unlikely(revents & EV_ERROR)) { |
|
780
|
0 |
382 |
if (server->request_ready_rinq) |
|
811
|
142 |
583 |
if (c->is_keepalive && c->rbuf) { |
|
|
136 |
6 |
if (c->is_keepalive && c->rbuf) { |
|
815
|
14 |
122 |
if (body_total > 0) { |
|
818
|
5 |
9 |
if (remaining > 0 && remaining <= (ssize_t)SvCUR(c->rbuf)) { |
|
|
5 |
0 |
if (remaining > 0 && remaining <= (ssize_t)SvCUR(c->rbuf)) { |
|
826
|
142 |
583 |
if (c->is_keepalive) { |
|
830
|
136 |
6 |
if (c->rbuf) { pipelined = SvCUR(c->rbuf); } |
|
831
|
142 |
0 |
if (likely(c->req)) { |
|
832
|
36 |
106 |
if (likely(pipelined == 0) && c->req->buf && c->rbuf) { |
|
|
36 |
0 |
if (likely(pipelined == 0) && c->req->buf && c->rbuf) { |
|
|
30 |
6 |
if (likely(pipelined == 0) && c->req->buf && c->rbuf) { |
|
839
|
0 |
30 |
if (SvLEN(c->rbuf) > READ_BUFSZ * 4) |
|
842
|
112 |
0 |
} else if (c->req->buf) { |
|
848
|
106 |
36 |
if (unlikely(pipelined > 0 && c->is_http11)) { |
|
|
106 |
0 |
if (unlikely(pipelined > 0 && c->is_http11)) { |
|
850
|
106 |
0 |
if (c->pipeline_depth <= MAX_PIPELINE_DEPTH) { |
|
866
|
0 |
583 |
if (c->responding != RESPOND_SHUTDOWN) |
|
883
|
0 |
725 |
if (unlikely(revents & EV_ERROR && !(revents & EV_WRITE))) { |
|
|
0 |
0 |
if (unlikely(revents & EV_ERROR && !(revents & EV_WRITE))) { |
|
889
|
23 |
702 |
if (unlikely(!c->wbuf_rinq)) { |
|
890
|
3 |
20 |
if (unlikely(c->responding >= RESPOND_SHUTDOWN)) |
|
895
|
0 |
20 |
if (c->sendfile_fd >= 0) |
|
899
|
0 |
20 |
if (!c->poll_write_cb) { |
|
901
|
0 |
0 |
if (c->responding == RESPOND_STREAMING) |
|
909
|
11 |
9 |
if (c->poll_write_cb_is_io_handle) |
|
915
|
0 |
20 |
if (unlikely(!c->wbuf_rinq)) goto try_write_again; |
|
918
|
701 |
1 |
else if (c->cached_wbuf_low_water > 0 |
|
919
|
0 |
1 |
&& c->wbuf_len <= c->cached_wbuf_low_water |
|
920
|
0 |
1 |
&& c->responding == RESPOND_STREAMING && c->poll_write_cb) { |
|
|
0 |
1 |
&& c->responding == RESPOND_STREAMING && c->poll_write_cb) { |
|
921
|
0 |
1 |
if (c->poll_write_cb_is_io_handle) |
|
930
|
3 |
719 |
if (c->sendfile_fd >= 0) |
|
946
|
0 |
722 |
if (iov_count > IOV_MAX) iov_count = IOV_MAX; |
|
949
|
645 |
77 |
if (iov_count == 1) { |
|
957
|
0 |
722 |
if (unlikely(wrote <= 0)) { |
|
958
|
0 |
0 |
if (likely(errno == EAGAIN || errno == EINTR)) |
|
|
0 |
0 |
if (likely(errno == EAGAIN || errno == EINTR)) |
|
961
|
0 |
0 |
CLOSE_SENDFILE_FD(c); |
|
|
0 |
0 |
CLOSE_SENDFILE_FD(c); |
|
972
|
961 |
722 |
for (i = m->offset; i < m->count && consume; i++) { |
|
|
961 |
0 |
for (i = m->offset; i < m->count && consume; i++) { |
|
974
|
0 |
961 |
if (unlikely(v->iov_len > wrote)) { |
|
987
|
858 |
103 |
if (m->sv[i]) { |
|
994
|
722 |
0 |
if (likely(m->offset >= m->count)) { |
|
997
|
722 |
0 |
IOMATRIX_FREE(m); |
|
998
|
722 |
0 |
if (!c->wbuf_rinq) { |
|
1001
|
3 |
719 |
if (c->sendfile_fd >= 0) |
|
1007
|
0 |
0 |
if (c->cached_wbuf_low_water > 0 |
|
1008
|
0 |
0 |
&& c->wbuf_len <= c->cached_wbuf_low_water |
|
1009
|
0 |
0 |
&& c->responding == RESPOND_STREAMING && c->poll_write_cb) { |
|
|
0 |
0 |
&& c->responding == RESPOND_STREAMING && c->poll_write_cb) { |
|
1026
|
3 |
0 |
if (sent > 0) { |
|
1029
|
3 |
0 |
if (c->sendfile_remain == 0) { |
|
1030
|
3 |
0 |
CLOSE_SENDFILE_FD(c); |
|
|
0 |
3 |
CLOSE_SENDFILE_FD(c); |
|
1038
|
0 |
0 |
else if (sent == 0) { |
|
1040
|
0 |
0 |
CLOSE_SENDFILE_FD(c); |
|
|
0 |
0 |
CLOSE_SENDFILE_FD(c); |
|
1042
|
0 |
0 |
if (c->responding == RESPOND_STREAMING) { |
|
1049
|
0 |
0 |
if (errno == EAGAIN || errno == EINTR) { |
|
|
0 |
0 |
if (errno == EAGAIN || errno == EINTR) { |
|
1055
|
0 |
0 |
CLOSE_SENDFILE_FD(c); |
|
|
0 |
0 |
CLOSE_SENDFILE_FD(c); |
|
1079
|
14 |
36 |
if (c->poll_write_cb) goto try_write_again; |
|
1111
|
21 |
133 |
if (len < 8) |
|
1115
|
0 |
133 |
if (memcmp(buf, PROXY_V1_PREFIX, PROXY_V1_PREFIX_LEN) != 0) |
|
1121
|
2949 |
103 |
for (STRLEN i = PROXY_V1_PREFIX_LEN; i < search_len - 1; i++) { |
|
1122
|
30 |
2919 |
if (buf[i] == '\r' && buf[i+1] == '\n') { |
|
|
30 |
0 |
if (buf[i] == '\r' && buf[i+1] == '\n') { |
|
1128
|
103 |
30 |
if (!crlf) { |
|
1129
|
1 |
102 |
if (len >= PROXY_V1_MAX_LINE) |
|
1143
|
1 |
29 |
if (strncmp(p, "UNKNOWN", 7) == 0 && (p[7] == '\0' || p[7] == ' ')) { |
|
|
0 |
1 |
if (strncmp(p, "UNKNOWN", 7) == 0 && (p[7] == '\0' || p[7] == ' ')) { |
|
|
0 |
0 |
if (strncmp(p, "UNKNOWN", 7) == 0 && (p[7] == '\0' || p[7] == ' ')) { |
|
1152
|
26 |
3 |
if (strncmp(p, "TCP4 ", 5) == 0) { |
|
1154
|
2 |
1 |
} else if (strncmp(p, "TCP6 ", 5) == 0) { |
|
1167
|
0 |
28 |
if (sscanf(p, "%45s %45s %d %d", src_addr, dst_addr, &src_port, &dst_port) != 4) { |
|
1173
|
28 |
0 |
if (src_port < 0 || src_port > 65535 || dst_port < 0 || dst_port > 65535) { |
|
|
27 |
1 |
if (src_port < 0 || src_port > 65535 || dst_port < 0 || dst_port > 65535) { |
|
|
27 |
0 |
if (src_port < 0 || src_port > 65535 || dst_port < 0 || dst_port > 65535) { |
|
|
0 |
27 |
if (src_port < 0 || src_port > 65535 || dst_port < 0 || dst_port > 65535) { |
|
1181
|
2 |
25 |
if (is_ipv6) { |
|
1184
|
0 |
2 |
if (inet_pton(AF_INET6, src_addr, &sa6->sin6_addr) != 1) { |
|
1191
|
1 |
24 |
if (inet_pton(AF_INET, src_addr, &sa4->sin_addr) != 1) { |
|
1212
|
3 |
107 |
if (len < PROXY_V2_HDR_MIN) |
|
1216
|
20 |
87 |
if (memcmp(buf, PROXY_V2_SIG, PROXY_V2_SIG_LEN) != 0) |
|
1224
|
44 |
43 |
if (version != PROXY_V2_VERSION) |
|
1233
|
3 |
40 |
if (unlikely(addr_len > 4096)) { /* spec allows 65535, cap for sanity */ |
|
1240
|
5 |
35 |
if (len < total_len) |
|
1244
|
1 |
34 |
if (command == PROXY_V2_CMD_LOCAL) { |
|
1251
|
0 |
34 |
if (command != PROXY_V2_CMD_PROXY) { |
|
1258
|
32 |
2 |
if (family == PROXY_V2_FAM_INET) { |
|
1260
|
0 |
32 |
if (addr_len < PROXY_V2_ADDR_V4_LEN) |
|
1276
|
1 |
1 |
} else if (family == PROXY_V2_FAM_INET6) { |
|
1278
|
0 |
1 |
if (addr_len < PROXY_V2_ADDR_V6_LEN) |
|
1292
|
0 |
1 |
} else if (family == PROXY_V2_FAM_UNSPEC) { |
|
1301
|
32 |
2 |
if (family == PROXY_V2_FAM_INET) addr_size = PROXY_V2_ADDR_V4_LEN; |
|
1302
|
1 |
1 |
else if (family == PROXY_V2_FAM_INET6) addr_size = PROXY_V2_ADDR_V6_LEN; |
|
1304
|
13 |
21 |
if (addr_len > addr_size) { |
|
1314
|
14 |
3 |
while (tlv_remaining >= 3) { // minimum TLV: 1 type + 2 length |
|
1317
|
0 |
14 |
if (++tlv_count > 64) { |
|
1325
|
10 |
4 |
if (tlv_remaining < 3 + (size_t)tlv_len) { |
|
1335
|
2 |
2 |
if (tlv_type == PP2_TYPE_SSL && tlv_len >= 5) { |
|
|
2 |
0 |
if (tlv_type == PP2_TYPE_SSL && tlv_len >= 5) { |
|
1341
|
4 |
0 |
if (tlv_type != PP2_TYPE_NOOP) { |
|
1354
|
0 |
3 |
if (HvKEYS(tlv_hv) > 0) { |
|
|
3 |
0 |
if (HvKEYS(tlv_hv) > 0) { |
|
1370
|
0 |
288 |
if (SvCUR(c->rbuf) == 0) |
|
1375
|
154 |
134 |
if (first == 'P') { |
|
1377
|
110 |
24 |
} else if (first == 0x0D) { |