Data-Log-Shared
view release on metacpan or search on metacpan
RETVAL = (off >= 0) ? newSViv((IV)off) : &PL_sv_undef;
OUTPUT:
RETVAL
void
read_entry(self, offset, ...)
SV *self
UV offset
PREINIT:
EXTRACT_LOG(self);
PPCODE:
const uint8_t *out_data;
uint32_t out_len;
int out_utf8 = 0;
uint64_t next_off;
/* Optional third arg: abandon_wait_us (default LOG_ABANDON_WAIT_US).
* Pass 0 to immediately treat any uncommitted slot as abandoned. */
uint64_t wait_us = (items > 2 && (SvGETMAGIC(ST(2)), SvOK(ST(2)))) ? (uint64_t)SvUV(ST(2)) : (uint64_t)LOG_ABANDON_WAIT_US;
REEXTRACT_LOG(self);
int rc = log_read_ex(h, offset, &out_data, &out_len, &out_utf8, &next_off, wait_us);
if (rc == LOG_READ_OK) {
xt/destroy_during_call.t view on Meta::CPAN
# Argument magic that explicitly calls $obj->DESTROY frees the C handle
# mid-method. Without the REEXTRACT_LOG calls the method then dereferences
# a handle whose header was munmapped by log_destroy and SEGFAULTs; with
# them it must croak cleanly. Child exit 0 = croaked (correct), exit 7 =
# ran on through freed memory (REEXTRACT removed and no crash).
#
# Magic placement note: for read_entry/wait_for the offset/expected_count
# UV is converted by the INPUT typemap BEFORE EXTRACT_LOG (PREINIT) runs,
# so magic on that argument would croak in EXTRACT even without REEXTRACT
# -- a passes-either-way test. The discriminating window is the optional
# third argument (abandon_wait_us / timeout), read in PPCODE/CODE after
# EXTRACT_LOG and before REEXTRACT_LOG. append's data is a raw SV* whose
# SvPV runs in the same window, so it can carry the magic directly.
{
package Evil;
use overload
'""' => sub { $_[0][0]->DESTROY; 'k' },
'0+' => sub { $_[0][0]->DESTROY; 0 },
fallback => 1;
}
( run in 0.670 second using v1.01-cache-2.11-cpan-92ad3014f07 )