Branch Coverage

Shared.xs
Criterion Covered Total %
branch 344 588 58.5


line true false branch
129 30 9 const char *p = SvOK(path) ? SvPV_nolen(path) : NULL;
131 2 37 if (!h) croak("Data::Queue::Shared::Int->new: %s", errbuf);
145 0 6 if (!h) croak("Data::Queue::Shared::Int->new_memfd: %s", errbuf);
158 0 1 if (!h) croak("Data::Queue::Shared::Int->new_from_fd: %s", errbuf);
167 2 0 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
0 2 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
0 2 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
169 0 2 RETVAL = h->backing_fd;
177 0 44 if (!SvROK(self)) return;
179 0 44 if (!h) return;
188 192 0 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
0 192 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
0 192 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
190 188 4 RETVAL = queue_int_try_push(h, (int64_t)value);
198 100 0 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
0 100 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
0 100 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
201 96 4 if (queue_int_try_pop(h, &value))
213 2 0 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
0 2 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
0 2 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
216 2 0 if (items > 2) timeout = SvNV(ST(2));
217 1 1 RETVAL = queue_int_push_wait(h, (int64_t)value, timeout);
225 104 0 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
0 104 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
0 104 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
229 104 0 if (items > 1) timeout = SvNV(ST(1));
230 103 1 if (queue_int_pop_wait(h, &value, timeout))
241 3 0 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
0 3 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
0 3 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
245 11 2 for (uint32_t i = 0; i < count; i++) {
246 1 10 if (!queue_int_try_push(h, (int64_t)SvIV(ST(i + 1)))) break;
250 0 3 RETVAL = pushed;
259 2 0 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
0 2 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
0 2 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
262 6 1 for (UV i = 0; i < count; i++) {
263 1 5 if (!queue_int_try_pop(h, &value)) break;
264 0 5 mXPUSHi((IV)value);
271 14 0 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
0 14 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
0 14 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
281 7 0 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
0 7 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
0 7 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
283 0 7 RETVAL = h->capacity;
291 5 0 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
0 5 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
0 5 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
293 4 1 RETVAL = (queue_int_size(h) == 0);
301 3 0 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
0 3 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
0 3 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
303 2 1 RETVAL = (queue_int_size(h) >= h->capacity);
311 5 0 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
0 5 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
0 5 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
320 7 1 if (sv_isobject(self_or_class)) {
322 0 7 if (!h) croak("Attempted to use a destroyed object");
325 0 1 if (items < 2) croak("Usage: Data::Queue::Shared::Int->unlink($path)");
328 2 6 if (!path) croak("cannot unlink anonymous or memfd queue");
329 0 6 if (unlink(path) != 0)
336 3 0 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
0 3 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
0 3 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
338 1 2 RETVAL = h->path ? newSVpv(h->path, 0) : &PL_sv_undef;
346 6 0 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
0 6 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
0 6 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
368 9 0 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
0 9 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
0 9 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
371 6 3 if (queue_int_peek(h, &value))
382 12 0 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
0 12 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
0 12 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
386 1 11 max_count = (items > 1) ? (uint32_t)SvUV(ST(1)) : UINT32_MAX;
387 65 1 while (max_count-- > 0 && queue_int_try_pop(h, &value))
54 11 while (max_count-- > 0 && queue_int_try_pop(h, &value))
388 0 54 mXPUSHi((IV)value);
395 3 0 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
0 3 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
0 3 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
399 3 0 if (items > 2) timeout = SvNV(ST(2));
401 1 2 if (!queue_int_pop_wait(h, &value, timeout)) XSRETURN(0);
402 0 2 mXPUSHi((IV)value);
404 8 0 for (UV i = 1; i < count; i++) {
405 2 6 if (!queue_int_try_pop(h, &value)) break;
406 0 6 mXPUSHi((IV)value);
414 3 0 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
0 3 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
0 3 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
418 11 2 for (uint32_t i = 0; i < nvalues; i++) {
419 1 10 if (!queue_int_push_wait(h, (int64_t)SvIV(ST(i + 2)), timeout)) break;
429 2 0 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
0 2 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
0 2 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
431 0 2 if (queue_sync(h) != 0)
438 8 0 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
0 8 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
0 8 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
441 0 8 if (RETVAL < 0) croak("eventfd: %s", strerror(errno));
450 1 0 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
0 1 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
0 1 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
458 3 0 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
0 3 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
0 3 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
460 0 3 RETVAL = h->notify_fd;
468 6 0 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
0 6 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
0 6 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
471 6 0 RETVAL = (v >= 0) ? newSViv((IV)v) : &PL_sv_undef;
479 5 0 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
0 5 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
0 5 EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
494 14 23 if (items > 3)
498 32 5 const char *p = SvOK(path) ? SvPV_nolen(path) : NULL;
500 1 36 if (!h) croak("Data::Queue::Shared::Str->new: %s", errbuf);
514 1 3 if (items > 3)
519 0 4 if (!h) croak("Data::Queue::Shared::Str->new_memfd: %s", errbuf);
532 0 1 if (!h) croak("Data::Queue::Shared::Str->new_from_fd: %s", errbuf);
541 3 0 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
0 3 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
0 3 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
543 0 3 RETVAL = h->backing_fd;
551 0 41 if (!SvROK(self)) return;
553 0 41 if (!h) return;
562 170 0 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
0 170 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
0 170 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
568 0 170 if (r == -2) croak("Data::Queue::Shared::Str: string too long (max 2GB)");
569 167 3 RETVAL = (r == 1);
577 84 0 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
0 84 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
0 84 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
583 81 3 if (r == 1) {
585 3 78 if (utf8) SvUTF8_on(RETVAL);
586 0 3 } else if (r == -1) {
599 2 0 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
0 2 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
0 2 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
603 2 0 if (items > 2) timeout = SvNV(ST(2));
607 0 2 if (r == -2) croak("Data::Queue::Shared::Str: string too long (max 2GB)");
608 1 1 RETVAL = (r == 1);
616 54 0 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
0 54 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
0 54 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
622 54 0 if (items > 1) timeout = SvNV(ST(1));
624 53 1 if (r == 1) {
626 0 53 if (utf8) SvUTF8_on(RETVAL);
627 0 1 } else if (r == -1) {
639 2 0 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
0 2 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
0 2 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
644 6 1 for (uint32_t i = 0; i < count; i++) {
650 0 6 if (r == -2) { queue_mutex_unlock(h->hdr); croak("Data::Queue::Shared::Str: string too long (max 2GB)"); }
651 1 5 if (r != 1) break;
655 2 0 if (pushed) queue_wake_consumers(h->hdr);
656 0 2 RETVAL = pushed;
665 1 0 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
0 1 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
0 1 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
676 1 0 if (count > 0) {
678 0 1 if (!items_buf) croak("Data::Queue::Shared::Str: out of memory");
681 2 1 for (UV i = 0; i < count; i++) {
683 0 2 if (last_r <= 0) break;
684 2 0 char *c = (char *)malloc(len ? len : 1);
685 0 2 if (!c) { oom = 1; break; }
686 2 0 if (len) memcpy(c, str, len);
694 1 0 EXTEND(SP, (SSize_t)n);
0 1 EXTEND(SP, (SSize_t)n);
695 2 1 for (UV j = 0; j < n; j++) {
697 0 2 if (items_buf[j].utf8) SvUTF8_on(sv);
702 1 0 if (last_r == -1 || oom) croak("Data::Queue::Shared::Str: out of memory");
0 1 if (last_r == -1 || oom) croak("Data::Queue::Shared::Str: out of memory");
708 6 0 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
0 6 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
0 6 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
718 1 0 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
0 1 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
0 1 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
720 0 1 RETVAL = h->capacity;
728 8 0 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
0 8 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
0 8 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
730 7 1 RETVAL = (queue_str_size(h) == 0);
738 3 0 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
0 3 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
0 3 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
740 2 1 RETVAL = (queue_str_size(h) >= h->capacity);
748 7 0 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
0 7 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
0 7 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
757 5 1 if (sv_isobject(self_or_class)) {
759 0 5 if (!h) croak("Attempted to use a destroyed object");
762 0 1 if (items < 2) croak("Usage: Data::Queue::Shared::Str->unlink($path)");
765 0 6 if (!path) croak("cannot unlink anonymous or memfd queue");
766 0 6 if (unlink(path) != 0)
773 2 0 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
0 2 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
0 2 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
775 1 1 RETVAL = h->path ? newSVpv(h->path, 0) : &PL_sv_undef;
783 9 0 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
0 9 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
0 9 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
807 7 0 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
0 7 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
0 7 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
813 6 1 if (r == 1) {
815 1 5 if (utf8) SvUTF8_on(RETVAL);
816 0 1 } else if (r == -1) {
829 14 0 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
0 14 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
0 14 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
835 0 14 if (r == -2) croak("Data::Queue::Shared::Str: string too long (max 2GB)");
836 13 1 RETVAL = (r == 1);
845 3 0 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
0 3 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
0 3 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
849 2 1 if (items > 2) timeout = SvNV(ST(2));
853 0 3 if (r == -2) croak("Data::Queue::Shared::Str: string too long (max 2GB)");
854 2 1 RETVAL = (r == 1);
862 8 0 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
0 8 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
0 8 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
868 1 7 max_count = (items > 1) ? (uint32_t)SvUV(ST(1)) : UINT32_MAX;
875 29 1 while (max_count-- > 0) {
877 7 22 if (last_r <= 0) break;
879 22 0 char *c = (char *)malloc(len ? len : 1);
880 22 0 if (!it || !c) { free(it); free(c); oom = 1; break; }
0 22 if (!it || !c) { free(it); free(c); oom = 1; break; }
881 22 0 if (len) memcpy(c, str, len);
883 15 7 if (drained_tail) drained_tail->next = it; else drained_head = it;
889 8 0 EXTEND(SP, (SSize_t)drained_n);
0 8 EXTEND(SP, (SSize_t)drained_n);
890 22 8 while (drained_head) {
893 0 22 if (it->utf8) SvUTF8_on(sv);
898 8 0 if (last_r == -1 || oom) croak("Data::Queue::Shared::Str: out of memory");
0 8 if (last_r == -1 || oom) croak("Data::Queue::Shared::Str: out of memory");
905 3 0 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
0 3 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
0 3 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
911 3 0 if (items > 2) timeout = SvNV(ST(2));
915 0 3 if (r == -1) croak("Data::Queue::Shared::Str: out of memory");
916 1 2 if (r != 1) XSRETURN(0);
918 0 2 if (utf8) SvUTF8_on(sv);
919 0 2 mXPUSHs(sv);
922 6 0 for (UV i = 1; i < count; i++) {
924 2 4 if (r <= 0) break;
926 0 4 if (utf8) SvUTF8_on(sv);
927 0 4 mXPUSHs(sv);
935 3 0 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
0 3 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
0 3 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
939 6 2 for (uint32_t i = 0; i < nvalues; i++) {
945 0 6 if (r == -2) croak("Data::Queue::Shared::Str: string too long (max 2GB)");
946 1 5 if (r != 1) break;
956 19 0 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
0 19 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
0 19 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
962 17 2 if (r == 1) {
964 1 16 if (utf8) SvUTF8_on(RETVAL);
965 0 2 } else if (r == -1) {
977 3 0 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
0 3 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
0 3 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
983 3 0 if (items > 1) timeout = SvNV(ST(1));
985 2 1 if (r == 1) {
987 0 2 if (utf8) SvUTF8_on(RETVAL);
988 0 1 } else if (r == -1) {
1000 2 0 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
0 2 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
0 2 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
1002 0 2 if (queue_sync(h) != 0)
1009 2 0 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
0 2 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
0 2 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
1012 0 2 if (RETVAL < 0) croak("eventfd: %s", strerror(errno));
1021 0 0 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
0 0 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
0 0 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
1029 0 0 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
0 0 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
0 0 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
1031 0 0 RETVAL = h->notify_fd;
1039 3 0 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
0 3 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
0 3 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
1042 3 0 RETVAL = (v >= 0) ? newSViv((IV)v) : &PL_sv_undef;
1050 2 0 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
0 2 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
0 2 EXTRACT_HANDLE("Data::Queue::Shared::Str", self);