| line |
true |
false |
branch |
|
7
|
0 |
184 |
if (elt == NULL) return NULL; |
|
9
|
4 |
180 |
if (unlikely(SvMAGICAL(sv))) sv = sv_2mortal(newSVsv(sv)); |
|
10
|
3 |
181 |
if (unlikely(!SvOK(sv))) return NULL; |
|
12
|
6 |
175 |
if (unlikely(SvROK(sv))) sv = SvRV(sv); |
|
23
|
767 |
241 |
if (!c->wbuf_rinq) { |
|
32
|
0 |
241 |
if (m->count >= FEERSUM_IOMATRIX_SIZE) { |
|
37
|
767 |
241 |
if (add_iomatrix) { |
|
39
|
675 |
92 |
IOMATRIX_ALLOC(m); |
|
56
|
1 |
320 |
if (unlikely(SvMAGICAL(sv))) { |
|
59
|
0 |
320 |
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 */ |
|
227
|
0 |
0 |
if (100 <= code && code <= 199) { |
|
|
0 |
0 |
if (100 <= code && code <= 199) { |
|
230
|
0 |
0 |
else if (200 <= code && code <= 299) { |
|
|
0 |
0 |
else if (200 <= code && code <= 299) { |
|
233
|
0 |
0 |
else if (300 <= code && code <= 399) { |
|
|
0 |
0 |
else if (300 <= code && code <= 399) { |
|
236
|
0 |
0 |
else if (400 <= code && code <= 499) { |
|
|
0 |
0 |
else if (400 <= code && code <= 499) { |
|
261
|
636 |
0 |
if (likely(is_tcp)) { |
|
262
|
0 |
636 |
if (unlikely(setsockopt(fd, SOL_TCP, TCP_NODELAY, &flags, sizeof(int)))) |
|
280
|
6 |
0 |
if (likely(c->cached_is_tcp)) { |
|
296
|
0 |
8 |
PUSHMARK(SP); |
|
301
|
8 |
0 |
if (SvTRUE(ERRSV)) |
|
|
1 |
7 |
if (SvTRUE(ERRSV)) |
|
302
|
1 |
0 |
sv_setsv(ERRSV, &PL_sv_undef); |
|
304
|
0 |
8 |
FREETMPS; |
|
311
|
589 |
636 |
if (unlikely(c->fd < 0)) |
|
323
|
0 |
636 |
CLOSE_SENDFILE_FD(c); |
|
|
0 |
0 |
CLOSE_SENDFILE_FD(c); |
|
327
|
68 |
568 |
if (c->tls && c->tls_handshake_done) { |
|
|
51 |
17 |
if (c->tls && c->tls_handshake_done) { |
|
331
|
51 |
0 |
if (closebuf.off > 0) { |
|
343
|
0 |
636 |
if (unlikely(close(c->fd) < 0)) |
|
354
|
636 |
0 |
SvUPGRADE(self, SVt_PVMG); // ensures sv_bless doesn't reallocate |
|
355
|
636 |
0 |
SvGROW(self, sizeof(struct feer_conn)); |
|
|
636 |
0 |
SvGROW(self, sizeof(struct feer_conn)); |
|
382
|
159 |
477 |
c->receiving = srvr->use_proxy_protocol ? RECEIVE_PROXY_HEADER : RECEIVE_HEADERS; |
|
386
|
68 |
568 |
if (lsnr->tls_ctx_ref) { |
|
437
|
0 |
1498 |
if (unlikely(!sv_isa(rv,"Feersum::Connection"))) |
|
453
|
0 |
665 |
if (unlikely(!SvROK(rv))) croak("Expected a reference"); |
|
456
|
665 |
0 |
if (likely( |
|
|
423 |
242 |
if (likely( |
|
|
423 |
0 |
if (likely( |
|
|
665 |
0 |
if (likely( |
|
462
|
87 |
578 |
if (uv == 0) { |
|
463
|
15 |
72 |
if (can_croak) croak("Operation not allowed: Handle is closed."); |
|
469
|
0 |
0 |
if (can_croak) |
|
480
|
78 |
305 |
sv_bless(sv, is_writer ? feer_conn_writer_stash : feer_conn_reader_stash); |
|
501
|
3328 |
208 |
for (i = 0; i < FEER_MAX_LISTENERS; i++) { |
|
514
|
208 |
0 |
SvUPGRADE(self, SVt_PVMG); |
|
515
|
208 |
0 |
SvGROW(self, sizeof(struct feer_server)); |
|
|
208 |
0 |
SvGROW(self, sizeof(struct feer_server)); |
|
536
|
27366 |
33 |
if (sv_isa(rv, "Feersum")) { |
|
540
|
33 |
0 |
if (SvPOK(rv) && strEQ(SvPV_nolen(rv), "Feersum")) { |
|
|
33 |
0 |
if (SvPOK(rv) && strEQ(SvPV_nolen(rv), "Feersum")) { |
|
541
|
0 |
33 |
if (unlikely(!default_server)) |
|
559
|
12 |
144 |
if (unlikely(ev_is_active(&c->read_ev_io))) |
|
568
|
847 |
135 |
if (unlikely(!ev_is_active(&c->read_ev_io))) |
|
577
|
119 |
21 |
if (likely(!ev_is_active(&c->read_ev_timer))) { |
|
587
|
876 |
115 |
if (unlikely(!ev_is_active(&c->read_ev_timer))) |
|
597
|
121 |
510 |
if (unlikely(ev_is_active(&c->write_ev_io))) |
|
606
|
286 |
510 |
if (unlikely(!ev_is_active(&c->write_ev_io))) |
|
615
|
763 |
1 |
if (c->cached_write_timeout <= 0.0) return; |
|
616
|
1 |
0 |
if (likely(!ev_is_active(&c->write_ev_timer))) { |
|
626
|
816 |
1 |
if (unlikely(!ev_is_active(&c->write_ev_timer))) |
|
635
|
959 |
763 |
if (unlikely(!ev_is_active(&c->header_ev_timer))) |
|
645
|
0 |
145 |
if (timeout <= 0.0) return; |
|
664
|
34 |
1679 |
if (c->idle_rinq_node) { |
|
673
|
0 |
36 |
if (c->idle_rinq_node) return; // already idle |
|
676
|
36 |
0 |
RINQ_NEW(node, c); |
|
|
0 |
0 |
RINQ_NEW(node, c); |
|
679
|
31 |
5 |
if (*head == NULL) { |
|
693
|
9 |
2 |
if (!srvr->idle_keepalive_rinq) return 0; |
|
696
|
0 |
2 |
if (unlikely(!c)) return 0; |
|
720
|
532 |
369 |
while (server->request_ready_rinq) { |
|
723
|
0 |
532 |
if (unlikely(!c)) break; |
|
727
|
504 |
28 |
if (likely(c->wbuf_rinq)) { |
|
756
|
0 |
158 |
if (unlikely(revents & EV_ERROR)) { |
|
762
|
156 |
2 |
if (!srvr->shutting_down) { |
|
763
|
243 |
156 |
for (i = 0; i < srvr->n_listeners; i++) { |
|
765
|
164 |
79 |
if (!ev_is_active(&lsnr->accept_w) && !lsnr->paused) { |
|
|
164 |
0 |
if (!ev_is_active(&lsnr->accept_w) && !lsnr->paused) { |
|
778
|
0 |
4894 |
if (unlikely(revents & EV_ERROR)) { |
|
785
|
369 |
4525 |
if (server->request_ready_rinq) |
|
795
|
0 |
366 |
if (unlikely(revents & EV_ERROR)) { |
|
801
|
0 |
366 |
if (server->request_ready_rinq) |
|
832
|
142 |
565 |
if (c->is_keepalive && c->rbuf) { |
|
|
136 |
6 |
if (c->is_keepalive && c->rbuf) { |
|
836
|
14 |
122 |
if (body_total > 0) { |
|
839
|
5 |
9 |
if (remaining > 0 && remaining <= (ssize_t)SvCUR(c->rbuf)) { |
|
|
5 |
0 |
if (remaining > 0 && remaining <= (ssize_t)SvCUR(c->rbuf)) { |
|
847
|
142 |
565 |
if (c->is_keepalive) { |
|
851
|
136 |
6 |
if (c->rbuf) { pipelined = SvCUR(c->rbuf); } |
|
852
|
142 |
0 |
if (likely(c->req)) { |
|
853
|
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) { |
|
860
|
0 |
30 |
if (SvLEN(c->rbuf) > READ_BUFSZ * 4) |
|
863
|
112 |
0 |
} else if (c->req->buf) { |
|
869
|
106 |
36 |
if (unlikely(pipelined > 0 && c->is_http11)) { |
|
|
106 |
0 |
if (unlikely(pipelined > 0 && c->is_http11)) { |
|
871
|
106 |
0 |
if (c->pipeline_depth <= MAX_PIPELINE_DEPTH) { |
|
891
|
0 |
565 |
if (c->responding != RESPOND_SHUTDOWN) |
|
908
|
0 |
707 |
if (unlikely(revents & EV_ERROR && !(revents & EV_WRITE))) { |
|
|
0 |
0 |
if (unlikely(revents & EV_ERROR && !(revents & EV_WRITE))) { |
|
914
|
23 |
684 |
if (unlikely(!c->wbuf_rinq)) { |
|
915
|
3 |
20 |
if (unlikely(c->responding >= RESPOND_SHUTDOWN)) |
|
920
|
0 |
20 |
if (c->sendfile_fd >= 0) |
|
924
|
0 |
20 |
if (!c->poll_write_cb) { |
|
926
|
0 |
0 |
if (c->responding == RESPOND_STREAMING) |
|
934
|
11 |
9 |
if (c->poll_write_cb_is_io_handle) |
|
940
|
0 |
20 |
if (unlikely(!c->wbuf_rinq)) goto try_write_again; |
|
943
|
683 |
1 |
else if (c->cached_wbuf_low_water > 0 |
|
944
|
0 |
1 |
&& c->wbuf_len <= c->cached_wbuf_low_water |
|
945
|
0 |
1 |
&& c->responding == RESPOND_STREAMING && c->poll_write_cb) { |
|
|
0 |
1 |
&& c->responding == RESPOND_STREAMING && c->poll_write_cb) { |
|
946
|
0 |
1 |
if (c->poll_write_cb_is_io_handle) |
|
955
|
3 |
701 |
if (c->sendfile_fd >= 0) |
|
971
|
0 |
704 |
if (iov_count > IOV_MAX) iov_count = IOV_MAX; |
|
974
|
627 |
77 |
if (iov_count == 1) { |
|
982
|
0 |
704 |
if (unlikely(wrote <= 0)) { |
|
983
|
0 |
0 |
if (likely(errno == EAGAIN || errno == EINTR)) |
|
|
0 |
0 |
if (likely(errno == EAGAIN || errno == EINTR)) |
|
986
|
0 |
0 |
CLOSE_SENDFILE_FD(c); |
|
|
0 |
0 |
CLOSE_SENDFILE_FD(c); |
|
997
|
943 |
704 |
for (i = m->offset; i < m->count && consume; i++) { |
|
|
943 |
0 |
for (i = m->offset; i < m->count && consume; i++) { |
|
999
|
0 |
943 |
if (unlikely(v->iov_len > wrote)) { |
|
1012
|
840 |
103 |
if (m->sv[i]) { |
|
1019
|
704 |
0 |
if (likely(m->offset >= m->count)) { |
|
1022
|
704 |
0 |
IOMATRIX_FREE(m); |
|
1023
|
704 |
0 |
if (!c->wbuf_rinq) { |
|
1026
|
3 |
701 |
if (c->sendfile_fd >= 0) |
|
1032
|
0 |
0 |
if (c->cached_wbuf_low_water > 0 |
|
1033
|
0 |
0 |
&& c->wbuf_len <= c->cached_wbuf_low_water |
|
1034
|
0 |
0 |
&& c->responding == RESPOND_STREAMING && c->poll_write_cb) { |
|
|
0 |
0 |
&& c->responding == RESPOND_STREAMING && c->poll_write_cb) { |
|
1051
|
3 |
0 |
if (sent > 0) { |
|
1054
|
3 |
0 |
if (c->sendfile_remain == 0) { |
|
1055
|
3 |
0 |
CLOSE_SENDFILE_FD(c); |
|
|
0 |
3 |
CLOSE_SENDFILE_FD(c); |
|
1063
|
0 |
0 |
else if (sent == 0) { |
|
1065
|
0 |
0 |
CLOSE_SENDFILE_FD(c); |
|
|
0 |
0 |
CLOSE_SENDFILE_FD(c); |
|
1067
|
0 |
0 |
if (c->responding == RESPOND_STREAMING) { |
|
1074
|
0 |
0 |
if (errno == EAGAIN || errno == EINTR) { |
|
|
0 |
0 |
if (errno == EAGAIN || errno == EINTR) { |
|
1080
|
0 |
0 |
CLOSE_SENDFILE_FD(c); |
|
|
0 |
0 |
CLOSE_SENDFILE_FD(c); |
|
1104
|
14 |
36 |
if (c->poll_write_cb) goto try_write_again; |
|
1136
|
21 |
134 |
if (len < 8) |
|
1140
|
1 |
133 |
if (memcmp(buf, PROXY_V1_PREFIX, PROXY_V1_PREFIX_LEN) != 0) |
|
1147
|
2949 |
103 |
for (i = PROXY_V1_PREFIX_LEN; i < search_len - 1; i++) { |
|
1148
|
30 |
2919 |
if (buf[i] == '\r' && buf[i+1] == '\n') { |
|
|
30 |
0 |
if (buf[i] == '\r' && buf[i+1] == '\n') { |
|
1154
|
103 |
30 |
if (!crlf) { |
|
1155
|
1 |
102 |
if (len >= PROXY_V1_MAX_LINE) |
|
1169
|
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] == ' ')) { |
|
1178
|
26 |
3 |
if (strncmp(p, "TCP4 ", 5) == 0) { |
|
1180
|
2 |
1 |
} else if (strncmp(p, "TCP6 ", 5) == 0) { |
|
1193
|
0 |
28 |
if (sscanf(p, "%45s %45s %d %d", src_addr, dst_addr, &src_port, &dst_port) != 4) { |
|
1199
|
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) { |
|
1207
|
2 |
25 |
if (is_ipv6) { |
|
1210
|
0 |
2 |
if (inet_pton(AF_INET6, src_addr, &sa6->sin6_addr) != 1) { |
|
1217
|
1 |
24 |
if (inet_pton(AF_INET, src_addr, &sa4->sin_addr) != 1) { |
|
1238
|
3 |
104 |
if (len < PROXY_V2_HDR_MIN) |
|
1242
|
26 |
78 |
if (memcmp(buf, PROXY_V2_SIG, PROXY_V2_SIG_LEN) != 0) |
|
1250
|
30 |
48 |
if (version != PROXY_V2_VERSION) |
|
1259
|
3 |
45 |
if (unlikely(addr_len > 4096)) { /* spec allows 65535, cap for sanity */ |
|
1266
|
3 |
42 |
if (len < total_len) |
|
1270
|
1 |
41 |
if (command == PROXY_V2_CMD_LOCAL) { |
|
1277
|
0 |
41 |
if (command != PROXY_V2_CMD_PROXY) { |
|
1284
|
39 |
2 |
if (family == PROXY_V2_FAM_INET) { |
|
1286
|
0 |
39 |
if (addr_len < PROXY_V2_ADDR_V4_LEN) |
|
1302
|
1 |
1 |
} else if (family == PROXY_V2_FAM_INET6) { |
|
1304
|
0 |
1 |
if (addr_len < PROXY_V2_ADDR_V6_LEN) |
|
1318
|
0 |
1 |
} else if (family == PROXY_V2_FAM_UNSPEC) { |
|
1327
|
39 |
2 |
if (family == PROXY_V2_FAM_INET) addr_size = PROXY_V2_ADDR_V4_LEN; |
|
1328
|
1 |
1 |
else if (family == PROXY_V2_FAM_INET6) addr_size = PROXY_V2_ADDR_V6_LEN; |
|
1330
|
18 |
23 |
if (addr_len > addr_size) { |
|
1339
|
19 |
3 |
while (tlv_remaining >= 3) { // minimum TLV: 1 type + 2 length |
|
1343
|
15 |
4 |
if (tlv_remaining < 3 + (size_t)tlv_len) { |
|
1353
|
2 |
2 |
if (tlv_type == PP2_TYPE_SSL && tlv_len >= 5) { |
|
|
2 |
0 |
if (tlv_type == PP2_TYPE_SSL && tlv_len >= 5) { |
|
1359
|
4 |
0 |
if (tlv_type != PP2_TYPE_NOOP) { |
|
1372
|
0 |
3 |
if (HvKEYS(tlv_hv) > 0) { |
|
|
3 |
0 |
if (HvKEYS(tlv_hv) > 0) { |
|
1388
|
0 |
288 |
if (SvCUR(c->rbuf) == 0) |
|
1393
|
155 |
133 |
if (first == 'P') { |
|
1395
|
107 |
26 |
} else if (first == 0x0D) { |