| line |
true |
false |
branch |
|
7
|
0 |
170 |
if (elt == NULL) return NULL; |
|
9
|
4 |
166 |
if (unlikely(SvMAGICAL(sv))) sv = sv_2mortal(newSVsv(sv)); |
|
10
|
3 |
167 |
if (unlikely(!SvOK(sv))) return NULL; |
|
12
|
6 |
161 |
if (unlikely(SvROK(sv))) sv = SvRV(sv); |
|
23
|
714 |
4946 |
if (!c->wbuf_rinq) { |
|
32
|
0 |
4946 |
if (m->count >= FEERSUM_IOMATRIX_SIZE) { |
|
37
|
714 |
4946 |
if (add_iomatrix) { |
|
39
|
631 |
83 |
IOMATRIX_ALLOC(m); |
|
56
|
2 |
2247 |
if (unlikely(SvMAGICAL(sv))) { |
|
59
|
0 |
2247 |
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
|
17 |
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) { |
|
259
|
589 |
0 |
if (likely(is_tcp)) { |
|
260
|
0 |
589 |
if (unlikely(setsockopt(fd, SOL_TCP, TCP_NODELAY, &flags, sizeof(int)))) |
|
278
|
6 |
0 |
if (likely(c->cached_is_tcp)) { |
|
294
|
0 |
6 |
PUSHMARK(SP); |
|
299
|
6 |
0 |
if (SvTRUE(ERRSV)) |
|
|
1 |
5 |
if (SvTRUE(ERRSV)) |
|
300
|
1 |
0 |
sv_setsv(ERRSV, &PL_sv_undef); |
|
302
|
0 |
6 |
FREETMPS; |
|
309
|
545 |
589 |
if (unlikely(c->fd < 0)) |
|
321
|
0 |
589 |
CLOSE_SENDFILE_FD(c); |
|
|
0 |
0 |
CLOSE_SENDFILE_FD(c); |
|
325
|
59 |
530 |
if (c->tls && c->tls_handshake_done) { |
|
|
42 |
17 |
if (c->tls && c->tls_handshake_done) { |
|
329
|
42 |
0 |
if (closebuf.off > 0) { |
|
341
|
0 |
589 |
if (unlikely(close(c->fd) < 0)) |
|
352
|
589 |
0 |
SvUPGRADE(self, SVt_PVMG); // ensures sv_bless doesn't reallocate |
|
353
|
589 |
0 |
SvGROW(self, sizeof(struct feer_conn)); |
|
|
589 |
0 |
SvGROW(self, sizeof(struct feer_conn)); |
|
380
|
154 |
435 |
c->receiving = srvr->use_proxy_protocol ? RECEIVE_PROXY_HEADER : RECEIVE_HEADERS; |
|
384
|
59 |
530 |
if (lsnr->tls_ctx_ref) { |
|
435
|
0 |
1382 |
if (unlikely(!sv_isa(rv,"Feersum::Connection"))) |
|
451
|
0 |
621 |
if (unlikely(!SvROK(rv))) croak("Expected a reference"); |
|
454
|
621 |
0 |
if (likely( |
|
|
383 |
238 |
if (likely( |
|
|
383 |
0 |
if (likely( |
|
|
621 |
0 |
if (likely( |
|
460
|
85 |
536 |
if (uv == 0) { |
|
461
|
15 |
70 |
if (can_croak) croak("Operation not allowed: Handle is closed."); |
|
467
|
0 |
0 |
if (can_croak) |
|
478
|
76 |
273 |
sv_bless(sv, is_writer ? feer_conn_writer_stash : feer_conn_reader_stash); |
|
496
|
2944 |
184 |
for (i = 0; i < FEER_MAX_LISTENERS; i++) { |
|
509
|
184 |
0 |
SvUPGRADE(self, SVt_PVMG); |
|
510
|
184 |
0 |
SvGROW(self, sizeof(struct feer_server)); |
|
|
184 |
0 |
SvGROW(self, sizeof(struct feer_server)); |
|
531
|
27220 |
33 |
if (sv_isa(rv, "Feersum")) { |
|
535
|
33 |
0 |
if (SvPOK(rv) && strEQ(SvPV_nolen(rv), "Feersum")) { |
|
|
33 |
0 |
if (SvPOK(rv) && strEQ(SvPV_nolen(rv), "Feersum")) { |
|
552
|
12 |
116 |
if (unlikely(ev_is_active(&c->read_ev_io))) |
|
561
|
799 |
109 |
if (unlikely(!ev_is_active(&c->read_ev_io))) |
|
570
|
97 |
20 |
if (likely(!ev_is_active(&c->read_ev_timer))) { |
|
580
|
816 |
95 |
if (unlikely(!ev_is_active(&c->read_ev_timer))) |
|
590
|
118 |
466 |
if (unlikely(ev_is_active(&c->write_ev_io))) |
|
599
|
269 |
466 |
if (unlikely(!ev_is_active(&c->write_ev_io))) |
|
608
|
710 |
1 |
if (c->cached_write_timeout <= 0.0) return; |
|
609
|
1 |
0 |
if (likely(!ev_is_active(&c->write_ev_timer))) { |
|
619
|
749 |
1 |
if (unlikely(!ev_is_active(&c->write_ev_timer))) |
|
628
|
879 |
702 |
if (unlikely(!ev_is_active(&c->header_ev_timer))) |
|
638
|
0 |
129 |
if (timeout <= 0.0) return; |
|
657
|
24 |
1553 |
if (c->idle_rinq_node) { |
|
666
|
0 |
25 |
if (c->idle_rinq_node) return; // already idle |
|
669
|
25 |
0 |
RINQ_NEW(node, c); |
|
|
0 |
0 |
RINQ_NEW(node, c); |
|
672
|
22 |
3 |
if (*head == NULL) { |
|
686
|
7 |
1 |
if (!srvr->idle_keepalive_rinq) return 0; |
|
689
|
0 |
1 |
if (unlikely(!c)) return 0; |
|
713
|
482 |
329 |
while (server->request_ready_rinq) { |
|
716
|
0 |
482 |
if (unlikely(!c)) break; |
|
720
|
460 |
22 |
if (likely(c->wbuf_rinq)) { |
|
748
|
0 |
138 |
if (unlikely(revents & EV_ERROR)) { |
|
754
|
138 |
0 |
if (!srvr->shutting_down) { |
|
755
|
219 |
138 |
for (i = 0; i < srvr->n_listeners; i++) { |
|
757
|
146 |
73 |
if (!ev_is_active(&lsnr->accept_w) && !lsnr->paused) { |
|
|
146 |
0 |
if (!ev_is_active(&lsnr->accept_w) && !lsnr->paused) { |
|
770
|
0 |
4534 |
if (unlikely(revents & EV_ERROR)) { |
|
777
|
329 |
4205 |
if (server->request_ready_rinq) |
|
787
|
0 |
326 |
if (unlikely(revents & EV_ERROR)) { |
|
793
|
0 |
326 |
if (server->request_ready_rinq) |
|
811
|
128 |
526 |
if (c->is_keepalive && c->expected_cl > 0 && c->rbuf) { |
|
|
12 |
116 |
if (c->is_keepalive && c->expected_cl > 0 && c->rbuf) { |
|
|
9 |
3 |
if (c->is_keepalive && c->expected_cl > 0 && c->rbuf) { |
|
813
|
2 |
7 |
if (consumed < c->expected_cl) { |
|
820
|
126 |
528 |
if (c->is_keepalive) { |
|
824
|
123 |
3 |
if (c->rbuf) { pipelined = SvCUR(c->rbuf); } |
|
825
|
126 |
0 |
if (likely(c->req)) { |
|
826
|
25 |
101 |
if (likely(pipelined == 0) && c->req->buf && c->rbuf) { |
|
|
25 |
0 |
if (likely(pipelined == 0) && c->req->buf && c->rbuf) { |
|
|
22 |
3 |
if (likely(pipelined == 0) && c->req->buf && c->rbuf) { |
|
832
|
104 |
0 |
} else if (c->req->buf) { |
|
838
|
101 |
25 |
if (unlikely(pipelined > 0 && c->is_http11)) { |
|
|
101 |
0 |
if (unlikely(pipelined > 0 && c->is_http11)) { |
|
840
|
101 |
0 |
if (c->pipeline_depth <= MAX_PIPELINE_DEPTH) { |
|
860
|
0 |
528 |
if (c->responding != RESPOND_SHUTDOWN) |
|
877
|
0 |
658 |
if (unlikely(revents & EV_ERROR && !(revents & EV_WRITE))) { |
|
|
0 |
0 |
if (unlikely(revents & EV_ERROR && !(revents & EV_WRITE))) { |
|
883
|
23 |
635 |
if (unlikely(!c->wbuf_rinq)) { |
|
884
|
3 |
20 |
if (unlikely(c->responding >= RESPOND_SHUTDOWN)) |
|
889
|
0 |
20 |
if (c->sendfile_fd >= 0) |
|
893
|
0 |
20 |
if (!c->poll_write_cb) { |
|
895
|
0 |
0 |
if (c->responding == RESPOND_STREAMING) |
|
903
|
11 |
9 |
if (c->poll_write_cb_is_io_handle) |
|
909
|
0 |
20 |
if (unlikely(!c->wbuf_rinq)) goto try_write_again; |
|
912
|
634 |
1 |
else if (c->cached_wbuf_low_water > 0 |
|
913
|
0 |
1 |
&& c->wbuf_len <= c->cached_wbuf_low_water |
|
914
|
0 |
1 |
&& c->responding == RESPOND_STREAMING && c->poll_write_cb) { |
|
|
0 |
1 |
&& c->responding == RESPOND_STREAMING && c->poll_write_cb) { |
|
915
|
0 |
1 |
if (c->poll_write_cb_is_io_handle) |
|
924
|
3 |
652 |
if (c->sendfile_fd >= 0) |
|
940
|
209 |
446 |
if (iov_count == 1) { |
|
948
|
0 |
655 |
if (unlikely(wrote <= 0)) { |
|
949
|
0 |
0 |
if (likely(errno == EAGAIN || errno == EINTR)) |
|
|
0 |
0 |
if (likely(errno == EAGAIN || errno == EINTR)) |
|
952
|
0 |
0 |
CLOSE_SENDFILE_FD(c); |
|
|
0 |
0 |
CLOSE_SENDFILE_FD(c); |
|
963
|
5055 |
655 |
for (i = m->offset; i < m->count && consume; i++) { |
|
|
5055 |
0 |
for (i = m->offset; i < m->count && consume; i++) { |
|
965
|
0 |
5055 |
if (unlikely(v->iov_len > wrote)) { |
|
978
|
2424 |
2631 |
if (m->sv[i]) { |
|
985
|
655 |
0 |
if (likely(m->offset >= m->count)) { |
|
988
|
655 |
0 |
IOMATRIX_FREE(m); |
|
989
|
655 |
0 |
if (!c->wbuf_rinq) { |
|
992
|
3 |
652 |
if (c->sendfile_fd >= 0) |
|
998
|
0 |
0 |
if (c->cached_wbuf_low_water > 0 |
|
999
|
0 |
0 |
&& c->wbuf_len <= c->cached_wbuf_low_water |
|
1000
|
0 |
0 |
&& c->responding == RESPOND_STREAMING && c->poll_write_cb) { |
|
|
0 |
0 |
&& c->responding == RESPOND_STREAMING && c->poll_write_cb) { |
|
1017
|
3 |
0 |
if (sent > 0) { |
|
1020
|
3 |
0 |
if (c->sendfile_remain == 0) { |
|
1021
|
3 |
0 |
CLOSE_SENDFILE_FD(c); |
|
|
0 |
3 |
CLOSE_SENDFILE_FD(c); |
|
1029
|
0 |
0 |
else if (sent == 0) { |
|
1031
|
0 |
0 |
CLOSE_SENDFILE_FD(c); |
|
|
0 |
0 |
CLOSE_SENDFILE_FD(c); |
|
1033
|
0 |
0 |
if (c->responding == RESPOND_STREAMING) { |
|
1040
|
0 |
0 |
if (errno == EAGAIN || errno == EINTR) { |
|
|
0 |
0 |
if (errno == EAGAIN || errno == EINTR) { |
|
1046
|
0 |
0 |
CLOSE_SENDFILE_FD(c); |
|
|
0 |
0 |
CLOSE_SENDFILE_FD(c); |
|
1070
|
14 |
36 |
if (c->poll_write_cb) goto try_write_again; |
|
1102
|
21 |
130 |
if (len < 8) |
|
1106
|
0 |
130 |
if (memcmp(buf, PROXY_V1_PREFIX, PROXY_V1_PREFIX_LEN) != 0) |
|
1113
|
2846 |
103 |
for (i = PROXY_V1_PREFIX_LEN; i < search_len - 1; i++) { |
|
1114
|
27 |
2819 |
if (buf[i] == '\r' && buf[i+1] == '\n') { |
|
|
27 |
0 |
if (buf[i] == '\r' && buf[i+1] == '\n') { |
|
1120
|
103 |
27 |
if (!crlf) { |
|
1121
|
1 |
102 |
if (len >= PROXY_V1_MAX_LINE) |
|
1135
|
1 |
26 |
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] == ' ')) { |
|
1144
|
23 |
3 |
if (strncmp(p, "TCP4 ", 5) == 0) { |
|
1146
|
2 |
1 |
} else if (strncmp(p, "TCP6 ", 5) == 0) { |
|
1159
|
0 |
25 |
if (sscanf(p, "%45s %45s %d %d", src_addr, dst_addr, &src_port, &dst_port) != 4) { |
|
1165
|
25 |
0 |
if (src_port < 0 || src_port > 65535 || dst_port < 0 || dst_port > 65535) { |
|
|
24 |
1 |
if (src_port < 0 || src_port > 65535 || dst_port < 0 || dst_port > 65535) { |
|
|
24 |
0 |
if (src_port < 0 || src_port > 65535 || dst_port < 0 || dst_port > 65535) { |
|
|
0 |
24 |
if (src_port < 0 || src_port > 65535 || dst_port < 0 || dst_port > 65535) { |
|
1173
|
2 |
22 |
if (is_ipv6) { |
|
1176
|
0 |
2 |
if (inet_pton(AF_INET6, src_addr, &sa6->sin6_addr) != 1) { |
|
1183
|
1 |
21 |
if (inet_pton(AF_INET, src_addr, &sa4->sin_addr) != 1) { |
|
1204
|
3 |
114 |
if (len < PROXY_V2_HDR_MIN) |
|
1208
|
27 |
87 |
if (memcmp(buf, PROXY_V2_SIG, PROXY_V2_SIG_LEN) != 0) |
|
1216
|
29 |
58 |
if (version != PROXY_V2_VERSION) |
|
1225
|
3 |
55 |
if (unlikely(addr_len > 4096)) { /* spec allows 65535, cap for sanity */ |
|
1232
|
3 |
52 |
if (len < total_len) |
|
1236
|
1 |
51 |
if (command == PROXY_V2_CMD_LOCAL) { |
|
1243
|
0 |
51 |
if (command != PROXY_V2_CMD_PROXY) { |
|
1250
|
49 |
2 |
if (family == PROXY_V2_FAM_INET) { |
|
1252
|
0 |
49 |
if (addr_len < PROXY_V2_ADDR_V4_LEN) |
|
1268
|
1 |
1 |
} else if (family == PROXY_V2_FAM_INET6) { |
|
1270
|
0 |
1 |
if (addr_len < PROXY_V2_ADDR_V6_LEN) |
|
1284
|
0 |
1 |
} else if (family == PROXY_V2_FAM_UNSPEC) { |
|
1293
|
49 |
2 |
if (family == PROXY_V2_FAM_INET) addr_size = PROXY_V2_ADDR_V4_LEN; |
|
1294
|
1 |
1 |
else if (family == PROXY_V2_FAM_INET6) addr_size = PROXY_V2_ADDR_V6_LEN; |
|
1296
|
22 |
29 |
if (addr_len > addr_size) { |
|
1305
|
22 |
4 |
while (tlv_remaining >= 3) { // minimum TLV: 1 type + 2 length |
|
1309
|
18 |
4 |
if (tlv_remaining < 3 + (size_t)tlv_len) { |
|
1319
|
2 |
2 |
if (tlv_type == PP2_TYPE_SSL && tlv_len >= 5) { |
|
|
2 |
0 |
if (tlv_type == PP2_TYPE_SSL && tlv_len >= 5) { |
|
1325
|
4 |
0 |
if (tlv_type != PP2_TYPE_NOOP) { |
|
1338
|
0 |
4 |
if (HvKEYS(tlv_hv) > 0) { |
|
|
3 |
1 |
if (HvKEYS(tlv_hv) > 0) { |
|
1354
|
0 |
283 |
if (SvCUR(c->rbuf) == 0) |
|
1359
|
151 |
132 |
if (first == 'P') { |
|
1361
|
117 |
15 |
} else if (first == 0x0D) { |