Branch Coverage

Event.xs
Criterion Covered Total %
branch 241 410 58.7


line true false branch
16 0 238 if (!sv_isobject(obj)) {
21 0 238 if (!SvIOK(rv)) {
31 1 42 UV new_cap = old_cap ? old_cap : 64;
33 7 43 while (fd >= new_cap) {
34 0 7 if (new_cap > (UV_MAX / 2)) {
40 0 43 Renew(r->slots, new_cap, SV *);
41 0 43 Zero(r->slots + old_cap, new_cap - old_cap, SV *);
57 0 108 if (!sv_isobject(obj)) {
61 0 108 if (!SvIOK(rv)) {
70 41 0 if (mask & 0x01) ev |= EPOLLIN;
71 5 36 if (mask & 0x02) ev |= EPOLLOUT;
73 0 41 if (mask & 0x04) ev |= EPOLLPRI;
76 0 41 if (mask & 0x08) ev |= EPOLLRDHUP;
79 1 40 if (mask & 0x10) ev |= EPOLLET;
82 5 36 if (mask & 0x20) ev |= EPOLLONESHOT;
90 24 0 if (ev & EPOLLIN) mask |= 0x01;
91 1 23 if (ev & EPOLLOUT) mask |= 0x02;
93 0 24 if (ev & EPOLLPRI) mask |= 0x04;
96 0 24 if (ev & EPOLLRDHUP) mask |= 0x08;
99 0 24 if (ev & EPOLLET) mask |= 0x10;
102 0 24 if (ev & EPOLLONESHOT) mask |= 0x20;
104 0 24 if (ev & EPOLLERR) mask |= 0x40;
105 1 23 if (ev & EPOLLHUP) mask |= 0x80;
111 3 30 if (!SvOK(timeout_s)) {
115 0 30 if (sec <= 0.0) {
119 0 30 if (ms > 2147483647.0) {
123 14 16 if ((double)out < ms) {
141 0 75 if (!sv_isobject(obj)) {
146 0 75 if (!SvIOK(rv)) {
177 0 212 if (!svp) {
185 24 0 if (fd < r->cap && r->slots[fd]) {
24 0 if (fd < r->cap && r->slots[fd]) {
188 24 0 if (r->count) r->count--;
205 3 5 return (svp && SvTRUE(*svp)) ? 1 : 0;
3 0 return (svp && SvTRUE(*svp)) ? 1 : 0;
210 1 0 if (!SvROK(ev) || SvTYPE(SvRV(ev)) != SVt_PVHV) {
0 1 if (!SvROK(ev) || SvTYPE(SvRV(ev)) != SVt_PVHV) {
217 1 0 if (le_hv_bool(hv, "in", 2)) m |= 0x01;
218 1 0 if (le_hv_bool(hv, "out", 3)) m |= 0x02;
219 0 1 if (le_hv_bool(hv, "prio", 4)) m |= 0x04;
220 0 1 if (le_hv_bool(hv, "rdhup", 5)) m |= 0x08;
221 0 1 if (le_hv_bool(hv, "et", 2)) m |= 0x10;
222 0 1 if (le_hv_bool(hv, "oneshot", 7)) m |= 0x20;
223 0 1 if (le_hv_bool(hv, "err", 3)) m |= 0x40;
224 1 0 if (le_hv_bool(hv, "hup", 3)) m |= 0x80;
249 0 165 if (!sv_isobject(obj)) {
253 0 165 if (!SvIOK(rv)) {
262 0 10 UV new_cap = old_cap ? old_cap : 64;
263 0 10 while (need >= new_cap) {
264 0 0 if (new_cap > (UV_MAX / 2)) croak("timer heap too large");
267 0 10 Renew(h->heap, new_cap, le_timer_entry_t);
268 10 0 if (new_cap > old_cap) {
269 0 10 Zero(h->heap + old_cap, new_cap - old_cap, le_timer_entry_t);
277 0 10 UV new_cap = old_cap ? old_cap : 64;
278 0 10 while (id >= new_cap) {
279 0 0 if (new_cap > (UV_MAX / 2)) croak("timer id table too large");
289 92 0 return (id < h->live_cap && h->live[id]) ? 1 : 0;
90 2 return (id < h->live_cap && h->live[id]) ? 1 : 0;
301 9 12 while (i > 0) {
303 7 2 if (h->heap[p].deadline_ns <= h->heap[i].deadline_ns) break;
313 8 4 if (l >= h->size) break;
316 1 3 if (r < h->size && h->heap[r].deadline_ns < h->heap[l].deadline_ns) m = r;
1 0 if (r < h->size && h->heap[r].deadline_ns < h->heap[l].deadline_ns) m = r;
317 1 3 if (h->heap[i].deadline_ns <= h->heap[m].deadline_ns) break;
325 0 18 if (h->size == 0) return;
328 9 9 if (h->size > 0) {
340 92 24 while (h->size && !le_timer_is_live(h, h->heap[0].id)) {
2 90 while (h->size && !le_timer_is_live(h, h->heap[0].id)) {
342 0 2 if (h->cancelled) h->cancelled--;
349 149 0 return (svp && SvTRUE(*svp)) ? 1 : 0;
74 75 return (svp && SvTRUE(*svp)) ? 1 : 0;
355 55 0 return svp ? *svp : &PL_sv_undef;
363 0 28 PUSHMARK(SP);
364 0 28 XPUSHs(sv_2mortal(newSVsv(loop)));
365 0 28 XPUSHs(sv_2mortal(newSVsv(fh)));
366 0 28 XPUSHs(sv_2mortal(newSVsv(watcher)));
369 28 0 FREETMPS;
375 26 0 if (!w->watcher || !SvOK(w->watcher) || !SvROK(w->watcher) || SvTYPE(SvRV(w->watcher)) != SVt_PVHV) {
26 0 if (!w->watcher || !SvOK(w->watcher) || !SvROK(w->watcher) || SvTYPE(SvRV(w->watcher)) != SVt_PVHV) {
26 0 if (!w->watcher || !SvOK(w->watcher) || !SvROK(w->watcher) || SvTYPE(SvRV(w->watcher)) != SVt_PVHV) {
0 26 if (!w->watcher || !SvOK(w->watcher) || !SvROK(w->watcher) || SvTYPE(SvRV(w->watcher)) != SVt_PVHV) {
380 0 26 if (!le_hv_true_key(whv, "active", 6)) {
385 0 26 if (!SvOK(fh)) {
392 2 24 if (mask & 0x40) {
394 1 1 if (SvOK(ecb) && le_hv_true_key(whv, "error_enabled", 13)) {
1 0 if (SvOK(ecb) && le_hv_true_key(whv, "error_enabled", 13)) {
402 2 23 if (mask & 0x80) {
406 25 0 if (read_trig && le_hv_true_key(whv, "read_enabled", 12)) {
25 0 if (read_trig && le_hv_true_key(whv, "read_enabled", 12)) {
408 25 0 if (SvOK(rcb)) {
413 5 20 if (!le_hv_true_key(whv, "active", 6)) {
417 2 18 if (write_trig && le_hv_true_key(whv, "write_enabled", 13)) {
2 0 if (write_trig && le_hv_true_key(whv, "write_enabled", 13)) {
419 2 0 if (SvOK(wcb)) {
448 31 22 if (fd >= r->cap || !r->slots[fd]) {
18 13 if (fd >= r->cap || !r->slots[fd]) {
464 5 3 if (fd >= r->cap) {
467 1 7 if (r->slots[fd]) {
481 3 0 if (fd >= r->cap || !r->slots[fd]) {
1 2 if (fd >= r->cap || !r->slots[fd]) {
497 0 5 RETVAL = r->count;
510 12 0 if (!SvROK(loop) || SvTYPE(SvRV(loop)) != SVt_PVHV) {
0 12 if (!SvROK(loop) || SvTYPE(SvRV(loop)) != SVt_PVHV) {
513 12 0 if (!SvROK(watcher) || SvTYPE(SvRV(watcher)) != SVt_PVHV) {
0 12 if (!SvROK(watcher) || SvTYPE(SvRV(watcher)) != SVt_PVHV) {
521 0 12 if (!SvTRUE(active)) {
533 12 0 if (!SvROK(backend_sv) || SvTYPE(SvRV(backend_sv)) != SVt_PVHV) {
0 12 if (!SvROK(backend_sv) || SvTYPE(SvRV(backend_sv)) != SVt_PVHV) {
541 0 12 if (ret < 0 && errno != ENOENT && errno != EBADF) {
0 0 if (ret < 0 && errno != ENOENT && errno != EBADF) {
0 0 if (ret < 0 && errno != ENOENT && errno != EBADF) {
569 38 0 if (SvOK(read_cb) && (!SvROK(read_cb) || SvTYPE(SvRV(read_cb)) != SVt_PVCV)) {
38 0 if (SvOK(read_cb) && (!SvROK(read_cb) || SvTYPE(SvRV(read_cb)) != SVt_PVCV)) {
0 38 if (SvOK(read_cb) && (!SvROK(read_cb) || SvTYPE(SvRV(read_cb)) != SVt_PVCV)) {
572 5 33 if (SvOK(write_cb) && (!SvROK(write_cb) || SvTYPE(SvRV(write_cb)) != SVt_PVCV)) {
5 0 if (SvOK(write_cb) && (!SvROK(write_cb) || SvTYPE(SvRV(write_cb)) != SVt_PVCV)) {
0 5 if (SvOK(write_cb) && (!SvROK(write_cb) || SvTYPE(SvRV(write_cb)) != SVt_PVCV)) {
575 1 37 if (SvOK(error_cb) && (!SvROK(error_cb) || SvTYPE(SvRV(error_cb)) != SVt_PVCV)) {
1 0 if (SvOK(error_cb) && (!SvROK(error_cb) || SvTYPE(SvRV(error_cb)) != SVt_PVCV)) {
0 1 if (SvOK(error_cb) && (!SvROK(error_cb) || SvTYPE(SvRV(error_cb)) != SVt_PVCV)) {
581 38 0 if (SvROK(fh_slot)) {
619 3 0 if (!SvROK(cb) || SvTYPE(SvRV(cb)) != SVt_PVCV) {
0 3 if (!SvROK(cb) || SvTYPE(SvRV(cb)) != SVt_PVCV) {
647 1 0 if (!SvROK(watcher) || SvTYPE(SvRV(watcher)) != SVt_PVHV) {
0 1 if (!SvROK(watcher) || SvTYPE(SvRV(watcher)) != SVt_PVHV) {
680 0 2 RETVAL = w->mask;
714 0 1 PUSHMARK(SP);
715 0 1 XPUSHs(sv_2mortal(newSVsv(w->loop)));
716 0 1 XPUSHs(sv_2mortal(newSVsv(w->fh)));
717 0 1 XPUSHs(sv_2mortal(newSViv(w->fd)));
718 0 1 XPUSHs(sv_2mortal(newSViv(mask)));
719 0 1 XPUSHs(sv_2mortal(newSVsv(w->tag)));
722 1 0 FREETMPS;
731 5 0 if (w->watcher && SvOK(w->watcher)) {
5 0 if (w->watcher && SvOK(w->watcher)) {
738 0 0 PUSHMARK(SP);
739 0 0 XPUSHs(sv_2mortal(newSVsv(w->loop)));
740 0 0 XPUSHs(sv_2mortal(newSVsv(w->fh)));
741 0 0 XPUSHs(sv_2mortal(newSViv(w->fd)));
742 0 0 XPUSHs(sv_2mortal(newSViv(mask)));
743 0 0 XPUSHs(sv_2mortal(newSVsv(w->tag)));
746 0 0 FREETMPS;
762 35 0 if (!SvROK(loop) || SvTYPE(SvRV(loop)) != SVt_PVHV) {
0 35 if (!SvROK(loop) || SvTYPE(SvRV(loop)) != SVt_PVHV) {
765 35 0 if (!SvROK(watcher) || SvTYPE(SvRV(watcher)) != SVt_PVHV) {
0 35 if (!SvROK(watcher) || SvTYPE(SvRV(watcher)) != SVt_PVHV) {
774 35 0 if (!SvROK(backend_sv) || SvTYPE(SvRV(backend_sv)) != SVt_PVHV) {
0 35 if (!SvROK(backend_sv) || SvTYPE(SvRV(backend_sv)) != SVt_PVHV) {
781 16 19 if ((UV)fd < breg->cap && breg->slots[(UV)fd]) {
0 16 if ((UV)fd < breg->cap && breg->slots[(UV)fd]) {
786 0 35 if (le_hv_true_key(bhv, "edge", 4)) eff_mask |= 0x10;
787 0 35 if (le_hv_true_key(bhv, "oneshot", 7)) eff_mask |= 0x20;
795 0 35 if (epoll_ctl(ep->epfd, EPOLL_CTL_ADD, (int)fd, &ev) < 0) {
801 19 16 if ((UV)fd >= watchers->cap) le_registry_grow(watchers, (UV)fd);
802 0 35 if (watchers->slots[(UV)fd]) SvREFCNT_dec(watchers->slots[(UV)fd]);
806 19 16 if ((UV)fd >= breg->cap) le_registry_grow(breg, (UV)fd);
807 0 35 if (breg->slots[(UV)fd]) SvREFCNT_dec(breg->slots[(UV)fd]);
812 25 10 RETVAL = 1;
836 19 0 if (!SvROK(cb) || SvTYPE(SvRV(cb)) != SVt_PVCV) {
0 19 if (!SvROK(cb) || SvTYPE(SvRV(cb)) != SVt_PVCV) {
841 10 9 if (id >= h->live_cap) le_timer_live_grow(h, id);
843 10 9 if (h->size >= h->cap) le_timer_heap_grow(h, h->size);
849 11 8 RETVAL = id;
859 3 0 if (id < h->live_cap && h->live[id]) {
2 1 if (id < h->live_cap && h->live[id]) {
876 23 53 if (!h->size) {
891 38 24 while (h->size) {
893 1 37 if (!h->size) break;
894 21 16 if (h->heap[0].deadline_ns > now_ns) break;
899 16 0 if (id < h->live_cap) h->live[id] = 0;
906 0 16 XPUSHs(sv_2mortal(newRV_noinc((SV *)av)));
914 0 0 RETVAL = h->size;
923 0 21 if (max_events <= 0) {
929 0 21 if (ep->epfd < 0) {
953 0 3 if (epoll_ctl(ep->epfd, EPOLL_CTL_ADD, (int)fd, &ev) < 0) {
968 0 3 if (epoll_ctl(ep->epfd, EPOLL_CTL_MOD, (int)fd, &ev) < 0) {
979 0 1 if (ret < 0) {
980 0 0 if (errno == ENOENT || errno == EBADF) {
0 0 if (errno == ENOENT || errno == EBADF) {
1005 0 33 } while (n < 0 && errno == EINTR);
0 0 } while (n < 0 && errno == EINTR);
1006 0 33 if (n < 0) {
1010 24 33 for (i = 0; i < n; i++) {
1012 24 0 if (fd < r->cap && r->slots[fd]) {
24 0 if (fd < r->cap && r->slots[fd]) {
1017 21 3 if (w->watcher && SvOK(w->watcher)) {
21 0 if (w->watcher && SvOK(w->watcher)) {
1024 0 3 PUSHMARK(SP);
1025 0 3 XPUSHs(sv_2mortal(newSVsv(w->loop)));
1026 0 3 XPUSHs(sv_2mortal(newSVsv(w->fh)));
1027 0 3 XPUSHs(sv_2mortal(newSViv(w->fd)));
1028 0 3 XPUSHs(sv_2mortal(newSViv(mask)));
1029 0 3 XPUSHs(sv_2mortal(newSVsv(w->tag)));
1032 3 0 FREETMPS;
1038 24 9 RETVAL = n;
1052 39 0 if (w) {
1057 36 3 if (w->watcher) SvREFCNT_dec(w->watcher);
1070 21 0 if (ep) {
1071 21 0 if (ep->epfd >= 0) {
1088 21 0 if (h) {
1090 1 21 for (i = 0; i < h->size; i++) {
1091 1 0 if (h->heap[i].cb) SvREFCNT_dec(h->heap[i].cb);
1108 42 0 if (r) {
1110 10816 42 for (i = 0; i < r->cap; i++) {
1111 51 10765 if (r->slots[i]) {