Branch Coverage

feersum_core.c.inc
Criterion Covered Total %
branch 249 394 63.2


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 765 241 if (!c->wbuf_rinq) {
32 0 241 if (m->count >= FEERSUM_IOMATRIX_SIZE) {
37 765 241 if (add_iomatrix) {
39 673 92 IOMATRIX_ALLOC(m);
56 1 318 if (unlikely(SvMAGICAL(sv))) {
59 0 318 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 587 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);
498 3328 208 for (i = 0; i < FEER_MAX_LISTENERS; i++) {
511 208 0 SvUPGRADE(self, SVt_PVMG);
512 208 0 SvGROW(self, sizeof(struct feer_server));
208 0 SvGROW(self, sizeof(struct feer_server));
533 27363 33 if (sv_isa(rv, "Feersum")) {
537 33 0 if (SvPOK(rv) && strEQ(SvPV_nolen(rv), "Feersum")) {
33 0 if (SvPOK(rv) && strEQ(SvPV_nolen(rv), "Feersum")) {
538 0 33 if (unlikely(!default_server))
556 12 146 if (unlikely(ev_is_active(&c->read_ev_io)))
565 843 137 if (unlikely(!ev_is_active(&c->read_ev_io)))
574 121 21 if (likely(!ev_is_active(&c->read_ev_timer))) {
584 872 117 if (unlikely(!ev_is_active(&c->read_ev_timer)))
594 121 510 if (unlikely(ev_is_active(&c->write_ev_io)))
603 286 510 if (unlikely(!ev_is_active(&c->write_ev_io)))
612 761 1 if (c->cached_write_timeout <= 0.0) return;
613 1 0 if (likely(!ev_is_active(&c->write_ev_timer))) {
623 816 1 if (unlikely(!ev_is_active(&c->write_ev_timer)))
632 957 763 if (unlikely(!ev_is_active(&c->header_ev_timer)))
642 0 145 if (timeout <= 0.0) return;
661 34 1681 if (c->idle_rinq_node) {
670 0 36 if (c->idle_rinq_node) return; // already idle
673 36 0 RINQ_NEW(node, c);
0 0 RINQ_NEW(node, c);
676 31 5 if (*head == NULL) {
690 9 2 if (!srvr->idle_keepalive_rinq) return 0;
693 0 2 if (unlikely(!c)) return 0;
717 532 369 while (server->request_ready_rinq) {
720 0 532 if (unlikely(!c)) break;
724 504 28 if (likely(c->wbuf_rinq)) {
753 0 158 if (unlikely(revents & EV_ERROR)) {
759 156 2 if (!srvr->shutting_down) {
760 243 156 for (i = 0; i < srvr->n_listeners; i++) {
762 164 79 if (!ev_is_active(&lsnr->accept_w) && !lsnr->paused) {
164 0 if (!ev_is_active(&lsnr->accept_w) && !lsnr->paused) {
775 0 4891 if (unlikely(revents & EV_ERROR)) {
782 369 4522 if (server->request_ready_rinq)
792 0 366 if (unlikely(revents & EV_ERROR)) {
798 0 366 if (server->request_ready_rinq)
825 142 563 if (c->is_keepalive && c->rbuf) {
136 6 if (c->is_keepalive && c->rbuf) {
829 14 122 if (body_total > 0) {
832 5 9 if (remaining > 0 && remaining <= (ssize_t)SvCUR(c->rbuf)) {
5 0 if (remaining > 0 && remaining <= (ssize_t)SvCUR(c->rbuf)) {
840 142 563 if (c->is_keepalive) {
844 136 6 if (c->rbuf) { pipelined = SvCUR(c->rbuf); }
845 142 0 if (likely(c->req)) {
846 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) {
852 112 0 } else if (c->req->buf) {
858 106 36 if (unlikely(pipelined > 0 && c->is_http11)) {
106 0 if (unlikely(pipelined > 0 && c->is_http11)) {
860 106 0 if (c->pipeline_depth <= MAX_PIPELINE_DEPTH) {
880 0 563 if (c->responding != RESPOND_SHUTDOWN)
897 0 705 if (unlikely(revents & EV_ERROR && !(revents & EV_WRITE))) {
0 0 if (unlikely(revents & EV_ERROR && !(revents & EV_WRITE))) {
903 23 682 if (unlikely(!c->wbuf_rinq)) {
904 3 20 if (unlikely(c->responding >= RESPOND_SHUTDOWN))
909 0 20 if (c->sendfile_fd >= 0)
913 0 20 if (!c->poll_write_cb) {
915 0 0 if (c->responding == RESPOND_STREAMING)
923 11 9 if (c->poll_write_cb_is_io_handle)
929 0 20 if (unlikely(!c->wbuf_rinq)) goto try_write_again;
932 681 1 else if (c->cached_wbuf_low_water > 0
933 0 1 && c->wbuf_len <= c->cached_wbuf_low_water
934 0 1 && c->responding == RESPOND_STREAMING && c->poll_write_cb) {
0 1 && c->responding == RESPOND_STREAMING && c->poll_write_cb) {
935 0 1 if (c->poll_write_cb_is_io_handle)
944 3 699 if (c->sendfile_fd >= 0)
960 625 77 if (iov_count == 1) {
968 0 702 if (unlikely(wrote <= 0)) {
969 0 0 if (likely(errno == EAGAIN || errno == EINTR))
0 0 if (likely(errno == EAGAIN || errno == EINTR))
972 0 0 CLOSE_SENDFILE_FD(c);
0 0 CLOSE_SENDFILE_FD(c);
983 941 702 for (i = m->offset; i < m->count && consume; i++) {
941 0 for (i = m->offset; i < m->count && consume; i++) {
985 0 941 if (unlikely(v->iov_len > wrote)) {
998 838 103 if (m->sv[i]) {
1005 702 0 if (likely(m->offset >= m->count)) {
1008 702 0 IOMATRIX_FREE(m);
1009 702 0 if (!c->wbuf_rinq) {
1012 3 699 if (c->sendfile_fd >= 0)
1018 0 0 if (c->cached_wbuf_low_water > 0
1019 0 0 && c->wbuf_len <= c->cached_wbuf_low_water
1020 0 0 && c->responding == RESPOND_STREAMING && c->poll_write_cb) {
0 0 && c->responding == RESPOND_STREAMING && c->poll_write_cb) {
1037 3 0 if (sent > 0) {
1040 3 0 if (c->sendfile_remain == 0) {
1041 3 0 CLOSE_SENDFILE_FD(c);
0 3 CLOSE_SENDFILE_FD(c);
1049 0 0 else if (sent == 0) {
1051 0 0 CLOSE_SENDFILE_FD(c);
0 0 CLOSE_SENDFILE_FD(c);
1053 0 0 if (c->responding == RESPOND_STREAMING) {
1060 0 0 if (errno == EAGAIN || errno == EINTR) {
0 0 if (errno == EAGAIN || errno == EINTR) {
1066 0 0 CLOSE_SENDFILE_FD(c);
0 0 CLOSE_SENDFILE_FD(c);
1090 14 36 if (c->poll_write_cb) goto try_write_again;
1122 21 133 if (len < 8)
1126 0 133 if (memcmp(buf, PROXY_V1_PREFIX, PROXY_V1_PREFIX_LEN) != 0)
1133 2949 103 for (i = PROXY_V1_PREFIX_LEN; i < search_len - 1; i++) {
1134 30 2919 if (buf[i] == '\r' && buf[i+1] == '\n') {
30 0 if (buf[i] == '\r' && buf[i+1] == '\n') {
1140 103 30 if (!crlf) {
1141 1 102 if (len >= PROXY_V1_MAX_LINE)
1155 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] == ' ')) {
1164 26 3 if (strncmp(p, "TCP4 ", 5) == 0) {
1166 2 1 } else if (strncmp(p, "TCP6 ", 5) == 0) {
1179 0 28 if (sscanf(p, "%45s %45s %d %d", src_addr, dst_addr, &src_port, &dst_port) != 4) {
1185 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) {
1193 2 25 if (is_ipv6) {
1196 0 2 if (inet_pton(AF_INET6, src_addr, &sa6->sin6_addr) != 1) {
1203 1 24 if (inet_pton(AF_INET, src_addr, &sa4->sin_addr) != 1) {
1224 3 108 if (len < PROXY_V2_HDR_MIN)
1228 24 84 if (memcmp(buf, PROXY_V2_SIG, PROXY_V2_SIG_LEN) != 0)
1236 38 46 if (version != PROXY_V2_VERSION)
1245 1 45 if (unlikely(addr_len > 4096)) { /* spec allows 65535, cap for sanity */
1252 5 40 if (len < total_len)
1256 1 39 if (command == PROXY_V2_CMD_LOCAL) {
1263 0 39 if (command != PROXY_V2_CMD_PROXY) {
1270 37 2 if (family == PROXY_V2_FAM_INET) {
1272 0 37 if (addr_len < PROXY_V2_ADDR_V4_LEN)
1288 1 1 } else if (family == PROXY_V2_FAM_INET6) {
1290 0 1 if (addr_len < PROXY_V2_ADDR_V6_LEN)
1304 0 1 } else if (family == PROXY_V2_FAM_UNSPEC) {
1313 37 2 if (family == PROXY_V2_FAM_INET) addr_size = PROXY_V2_ADDR_V4_LEN;
1314 1 1 else if (family == PROXY_V2_FAM_INET6) addr_size = PROXY_V2_ADDR_V6_LEN;
1316 20 19 if (addr_len > addr_size) {
1325 21 3 while (tlv_remaining >= 3) { // minimum TLV: 1 type + 2 length
1329 17 4 if (tlv_remaining < 3 + (size_t)tlv_len) {
1339 2 2 if (tlv_type == PP2_TYPE_SSL && tlv_len >= 5) {
2 0 if (tlv_type == PP2_TYPE_SSL && tlv_len >= 5) {
1345 4 0 if (tlv_type != PP2_TYPE_NOOP) {
1358 0 3 if (HvKEYS(tlv_hv) > 0) {
3 0 if (HvKEYS(tlv_hv) > 0) {
1374 0 288 if (SvCUR(c->rbuf) == 0)
1379 154 134 if (first == 'P') {
1381 111 23 } else if (first == 0x0D) {