view release on metacpan or search on metacpan
lib/Daemon/Device.pm view on Meta::CPAN
if ( $self->{_child} ) {
$self->{_child}->($self);
}
else {
while (1) {
exit unless ( $self->parent_alive );
sleep 1;
}
}
return;
lib/Daemon/Device.pm view on Meta::CPAN
my $self = shift;
$self->{_parent_hup_to_child} = $_[0] if (@_);
return $self->{_parent_hup_to_child};
}
sub parent_alive {
my ($self) = @_;
return kill( 0, $self->{_ppid} );
}
sub data {
lib/Daemon/Device.pm view on Meta::CPAN
sub child {
my ($device) = @_;
while (1) {
warn "Child $$ exists (heartbeat)\n";
exit unless ( $device->parent_alive );
sleep 5;
}
}
=head1 DESCRIPTION
lib/Daemon/Device.pm view on Meta::CPAN
child => sub {
my ($device) = @_;
while (1) {
warn "Child $$ exists (heartbeat)\n";
exit unless ( $device->parent_alive );
sleep 5;
}
},
)->run;
lib/Daemon/Device.pm view on Meta::CPAN
C<parent_hup_to_child> values, allowing you to change them during runtime.
This should be done in parents. Remember that data values are copied into
children during spawning (i.e. forking), so changing these values in children
is meaningless.
=head2 parent_alive
The C<parent_alive> method returns true if the daemon parent still lives or
false if it doesn't live. This is useful when writing child code, since a child
should periodically check to see if it's an orphan.
exit Daemon::Device->new(
daemon => \%daemon_control_settings,
child => sub {
my ($self) = @_;
while (1) {
exit unless ( $self->parent_alive );
sleep 1;
}
},
)->run;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Daemon/Easy.pm view on Meta::CPAN
=head1 SYNOPSIS
use Daemon::Easy sleep=>5, stopfile=>'stop', pidfile=>'pid', callback=>'worker';
sub worker{
print "i am alive\n";
}
run();
in the shell:
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Daemon/Generic/While1.pm view on Meta::CPAN
#
# We'll be getting a SIGTERM in a bit if we're not dead, so let's use it.
#
$SIG{TERM} = sub {
$self->gd_quit_event();
kill(15, $child) if $child; # if we're still alive, let's stay that way
};
};
}
sub gd_sleep
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dancer/Plugin/Database/Core.pm view on Meta::CPAN
return bless($dbh => $handle_class);
}
# Check the connection is alive
sub _check_connection {
my $dbh = shift;
return unless $dbh;
if ($dbh->{Active}) {
my $result = eval { $dbh->ping };
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dancer/Plugin/Database.pm view on Meta::CPAN
to do with DBI, but also adds a few convenience methods. See the documentation
for L<Dancer::Plugin::Database::Core::Handle> for full details of those.
Takes care of ensuring that the database handle is still connected and valid.
If the handle was last asked for more than C<connection_check_threshold> seconds
ago, it will check that the connection is still alive, using either the
C<< $dbh->ping >> method if the DBD driver supports it, or performing a simple
no-op query against the database if not. If the connection has gone away, a new
connection will be obtained and returned. This avoids any problems for
a long-running script where the connection to the database might go away.
view all matches for this distribution
view release on metacpan or search on metacpan
. add Dancer dependancy
. get Makefile.PL properly generated
0.306 2011-01-28 16:15:49 Europe/Paris
. Fix RT#65009 again
. flash messages are now smart enough to stay alive across multiple
requests, until they are used in templates ( thanks to Flavio Poletti
for the idea )
0.305 2011-01-23 19:20:17 Europe/Paris
. Fix RT#65009
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dancer/Plugin/LDAP.pm view on Meta::CPAN
$ldap->{dancer_settings} = $settings;
return bless $ldap, 'Dancer::Plugin::LDAP::Handle';
}
# Check whether the connection is alive
sub _check_connection {
my $ldap = shift;
return unless $ldap;
return unless $ldap->socket;
return 1;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dancer/Plugin/MPD.pm view on Meta::CPAN
=head1 DESCRIPTION
Provides an easy way to connect to MPD (L<www.musicpd.org>) from a L<Dancer>
app. Handles obtaining the connection, making sure the connection is still
alive, and reconnecting if not.
=head1 SYNOPSIS
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dancer/Plugin/Mango.pm view on Meta::CPAN
execute_hook('database_connected', $dbh);
return $dbh;
}
# Check the connection is alive
sub _check_connection {
my $dbh = shift;
return unless $dbh;
my $curs;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dancer/Plugin/MongoDB.pm view on Meta::CPAN
execute_hook('database_connected', $dbh);
return $dbh;
}
# Check the connection is alive
sub _check_connection {
my $dbh = shift;
return unless $dbh;
my $curs;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dancer/Plugin/StreamData.pm view on Meta::CPAN
my $psgi_callback = shift;
# Use the callback we were given to procure a writer object, and in the
# process pass the status and headers stored by prepare_stream() above.
# This will cause the HTTP response to be emitted, with a keep-alive
# header so that the client will know to wait for more data to come.
my $writer = $psgi_callback->( [ $stream_status, \@stream_headers ] );
# Now we call the routine specified in the original call to stream_data.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dancer/Request.pm view on Meta::CPAN
use URI;
use URI::Escape;
my @http_env_keys = (
'user_agent', 'accept_language', 'accept_charset',
'accept_encoding', 'keep_alive', 'connection', 'accept',
'accept_type', 'referer', #'host', managed manually
);
my $count = 0;
__PACKAGE__->attributes(
lib/Dancer/Request.pm view on Meta::CPAN
$self->{user_agent} = $env->{HTTP_USER_AGENT};
$self->{host} = $env->{HTTP_HOST};
$self->{accept_language} = $env->{HTTP_ACCEPT_LANGUAGE};
$self->{accept_charset} = $env->{HTTP_ACCEPT_CHARSET};
$self->{accept_encoding} = $env->{HTTP_ACCEPT_ENCODING};
$self->{keep_alive} = $env->{HTTP_KEEP_ALIVE};
$self->{connection} = $env->{HTTP_CONNECTION};
$self->{accept} = $env->{HTTP_ACCEPT};
$self->{accept_type} = $env->{HTTP_ACCEPT_TYPE};
$self->{referer} = $env->{HTTP_REFERER};
$self->{x_requested_with} = $env->{HTTP_X_REQUESTED_WITH};
lib/Dancer/Request.pm view on Meta::CPAN
=item C<host>
If you app is on a non-standard port, you can expect this to return the hostname
and port, e.g. C<example.com:5000>.
=item C<keep_alive>
=item C<path_info>
=item C<referer>
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dancer2/Plugin/Database.pm view on Meta::CPAN
to do with DBI, but also adds a few convenience methods. See the documentation
for L<Dancer::Plugin::Database::Core::Handle> for full details of those.
Takes care of ensuring that the database handle is still connected and valid.
If the handle was last asked for more than C<connection_check_threshold> seconds
ago, it will check that the connection is still alive, using either the
C<< $dbh->ping >> method if the DBD driver supports it, or performing a simple
no-op query against the database if not. If the connection has gone away, a new
connection will be obtained and returned. This avoids any problems for
a long-running script where the connection to the database might go away.
view all matches for this distribution
view release on metacpan or search on metacpan
CREATE_SAMPLE_APPLICATION view on Meta::CPAN
If you use an nginx web server to reverse proxy you service your app
vi nginx.conf
...
upstream TestService { server 127.0.0.1:3000 fail_timeout=0; keepalive 1024; }
...
server
{
server_name www.example.com;
listen 30080;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dancer2/Core/Request.pm view on Meta::CPAN
my @http_env_keys = (qw/
accept_charset
accept_encoding
accept_language
connection
keep_alive
x_requested_with
/);
# apparently you can't eval core functions
sub accept { $_[0]->env->{'HTTP_ACCEPT'} }
lib/Dancer2/Core/Request.pm view on Meta::CPAN
C<HTTP_X_FORWARDED_HOST>, since this is a comma separated list.
If you have not configured that you are behind a proxy, it returns HTTP
header C<HTTP_HOST>.
=item C<keep_alive>
HTTP header: C<HTTP_KEEP_ALIVE>.
=item C<referer>
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Danga/Socket/AnyEvent.pm view on Meta::CPAN
$cancel->();
};
$timer->[0] = $cancel;
# We save the watcher in $Timers to keep it alive until it runs,
# or until $cancel above overwrites it with undef to cause it to
# get collected.
$Timers{$key} = AnyEvent->timer(
after => $secs,
cb => _wrap_watcher_cb($cb),
view all matches for this distribution
view release on metacpan or search on metacpan
t/25_alias_weakref.t view on Meta::CPAN
skip "Scalar::Util not installed", 4
unless eval "use Scalar::Util qw/ weaken /; 42";
my $x = {};
my $y = {};
my $keepalive = $x;
weaken($x);
alias $x->{foo} = $y->{foo};
$x->{foo} = 42;
undef $keepalive;
is $x, undef;
is $y->{foo}, 42;
$x = [];
$keepalive = $x;
weaken($x);
alias push @$x, $y;
$y = 42;
is "@$keepalive", 42;
undef $keepalive;
is $x, undef;
}
# vim: ft=perl
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Data/AnyXfer/Elastic/Import/File/Simple.pm view on Meta::CPAN
# make sure it deserialises to an array ref
return $value = [@{$self->format->deserialise($value)}]
if $value;
# if we're still alive here
# we don't have a value, so the item must be new or empty
# so just return a ref to an empty array
# (but "touch" the item so it exists if we may need to write)
unless ($self->storage->read_only) {
$self->storage->set_item($from_item, $self->format->serialise([]));
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Data/Apache/mod_status/2XML.pm view on Meta::CPAN
<xsl:variable name="workers" select="/x:html/x:body/x:pre[1]/text()" />
<waiting><xsl:value-of select="string-length(translate($workers, translate($workers, '_', ''), ''))" /></waiting>
<starting><xsl:value-of select="string-length(translate($workers, translate($workers, 'S', ''), ''))" /></starting>
<reading><xsl:value-of select="string-length(translate($workers, translate($workers, 'R', ''), ''))" /></reading>
<sending><xsl:value-of select="string-length(translate($workers, translate($workers, 'W', ''), ''))" /></sending>
<keepalive><xsl:value-of select="string-length(translate($workers, translate($workers, 'K', ''), ''))" /></keepalive>
<dns_lookup><xsl:value-of select="string-length(translate($workers, translate($workers, 'D', ''), ''))" /></dns_lookup>
<closing><xsl:value-of select="string-length(translate($workers, translate($workers, 'C', ''), ''))" /></closing>
<logging><xsl:value-of select="string-length(translate($workers, translate($workers, 'L', ''), ''))" /></logging>
<finishing><xsl:value-of select="string-length(translate($workers, translate($workers, 'G', ''), ''))" /></finishing>
<idle_cleanup><xsl:value-of select="string-length(translate($workers, translate($workers, 'I', ''), ''))" /></idle_cleanup>
view all matches for this distribution
view release on metacpan or search on metacpan
#include "buf_str.h"
#include "XSParseKeyword.h"
/* ---- as_scalar magic: prevent use-after-free by preventing buffer DESTROY
* while the returned scalar ref is alive. We attach magic to the inner SV
* that holds a reference to the buffer object. When the inner SV is freed,
* the magic destructor releases the reference. ---- */
static int buf_scalar_magic_free(pTHX_ SV *sv, MAGIC *mg) {
PERL_UNUSED_ARG(sv);
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Data/Dump/Streamer.pm view on Meta::CPAN
# from link from [ysth]: http://groups.google.com/groups?selm=laUs8gzkgOlT092yn%40efn.org
# translate arg (or reference to it) into a B::* object
# To work-around perl commit
# 2acc3314e31a9342e325f35c5b592967c9850c9b, keep the
# value \*$lhs alive while we inspect it as a B object
# or else it'll be reaped while we're using it.
my $lhs_glob= \*$lhs;
my $Bobj= B::svref_2object($lhs_glob);
# if passed a glob or globref, get the format
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Data/Edit/Xml.pm view on Meta::CPAN
die "success!"; # Halt the search
}
});
};
confess $@ if $@ and $@ !~ /success!/; # Report any suppressed error messages at this point
$x # Return node found if we are still alive
}
sub firstSibling($@) #CYU Return the first sibling of the specified B<$node> in the optional B<@context> else B<undef>
{my ($node, @context) = @_; # Node, array of tags specifying context.
return undef if @context and !$node->at(@context); # Not in specified context
lib/Data/Edit/Xml.pm view on Meta::CPAN
die "success!"; # Halt the search
}
});
};
confess $@ if $@ and $@ !~ /success!/; # Report any suppressed error messages at this point
$x # Return node found if we are still alive
}
sub lastSibling($@) #CYU Return the last sibling of the specified B<$node> in the optional B<@context> else B<undef>
{my ($node, @context) = @_; # Node, array of tags specifying context.
return undef if @context and !$node->at(@context); # Not in specified context
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Data/FR/Town.pm view on Meta::CPAN
21574;;Saint-Seine-sur-Vingeanne;SAINT-SEINE-SUR-VINGEANNE;21610;21;COTE D'OR;1
21575;;Saint-Symphorien-sur-Saône;SAINT-SYMPHORIEN-SUR-SAONE;21170;21;COTE D'OR;1
21576;;Saint-Thibault;SAINT-THIBAULT;21350;21;COTE D'OR;1
21577;;Saint-Usage;SAINT-USAGE;21170;21;COTE D'OR;1
21578;;Saint-Victor-sur-Ouche;SAINT-VICTOR-SUR-OUCHE;21410;21;COTE D'OR;1
21579;;Salives;SALIVES;21580;21;COTE D'OR;1
21580;;Salmaise;SALMAISE;21690;21;COTE D'OR;1
21581;;Samerey;SAMEREY;21170;21;COTE D'OR;1
21582;;Santenay;SANTENAY;21590;21;COTE D'OR;1
21583;;Santosse;SANTOSSE;21340;21;COTE D'OR;1
21584;;Saulieu;SAULIEU;21210;21;COTE D'OR;1
lib/Data/FR/Town.pm view on Meta::CPAN
33535;;Tresses;TRESSES;33370;33;GIRONDE;1
33536;Le;Tuzan;TUZAN;33125;33;GIRONDE;1
33537;;Uzeste;UZESTE;33730;33;GIRONDE;1
33538;;Valeyrac;VALEYRAC;33340;33;GIRONDE;1
33539;;Vayres;VAYRES;33870;33;GIRONDE;1
33540;;Vendays-Montalivet;VENDAYS-MONTALIVET;33930;33;GIRONDE;1
33541;;Vensac;VENSAC;33590;33;GIRONDE;1
33542;;Vérac;VERAC;33240;33;GIRONDE;1
33543;;Verdelais;VERDELAIS;33490;33;GIRONDE;1
33544;Le;Verdon-sur-Mer;VERDON-SUR-MER;33123;33;GIRONDE;1
33545;;Vertheuil;VERTHEUIL;33180;33;GIRONDE;1
view all matches for this distribution
view release on metacpan or search on metacpan
* Mutex (same pattern as Heap)
* ================================================================ */
static const struct timespec graph_lock_timeout = { 2, 0 };
static inline int graph_pid_alive(uint32_t pid) {
if (pid == 0) return 1;
return !(kill((pid_t)pid, 0) == -1 && errno == ESRCH);
}
static inline void graph_mutex_lock(GraphHeader *hdr) {
if (cur != 0) {
long rc = syscall(SYS_futex, &hdr->mutex, FUTEX_WAIT, cur,
&graph_lock_timeout, NULL, 0);
if (rc == -1 && errno == ETIMEDOUT && cur >= GRAPH_MUTEX_BIT) {
uint32_t pid = cur & GRAPH_MUTEX_PID;
if (!graph_pid_alive(pid) &&
__atomic_compare_exchange_n(&hdr->mutex, &cur, 0,
0, __ATOMIC_ACQ_REL, __ATOMIC_RELAXED)) {
/* Recovered â wake one waiter so it can proceed. */
syscall(SYS_futex, &hdr->mutex, FUTEX_WAKE, 1, NULL, NULL, 0);
}
view all matches for this distribution
view release on metacpan or search on metacpan
my $v = shm_si_get $map, "counter";
printf "counter=%s (expired: %s)\n", $v // 'undef', defined $v ? 'no' : 'yes';
my $p = shm_si_get $map, "permanent";
printf "permanent=%s (still alive)\n", $p;
$map->unlink;
view all matches for this distribution
view release on metacpan or search on metacpan
sleep 1;
# Re-put refreshes TTL
hm_ii_put $m, 1, 20;
sleep 2;
# 3 seconds since original put, but only 2 since refresh (TTL=3)
is(hm_ii_get $m, 1, 20, 'TTL: put refresh keeps entry alive');
}
# ---- Iteration skips expired entries ----
{
view all matches for this distribution
view release on metacpan or search on metacpan
* Mutex (PID-based, stale-recoverable)
* ================================================================ */
static const struct timespec heap_lock_timeout = { 2, 0 };
static inline int heap_pid_alive(uint32_t pid) {
if (pid == 0) return 1;
return !(kill((pid_t)pid, 0) == -1 && errno == ESRCH);
}
static inline void heap_mutex_lock(HeapHeader *hdr) {
if (cur != 0) {
long rc = syscall(SYS_futex, &hdr->mutex, FUTEX_WAIT, cur,
&heap_lock_timeout, NULL, 0);
if (rc == -1 && errno == ETIMEDOUT && cur >= HEAP_MUTEX_BIT) {
uint32_t pid = cur & HEAP_MUTEX_PID;
if (!heap_pid_alive(pid)) {
if (__atomic_compare_exchange_n(&hdr->mutex, &cur, 0,
0, __ATOMIC_ACQ_REL, __ATOMIC_RELAXED)) {
__atomic_add_fetch(&hdr->stat_recoveries, 1, __ATOMIC_RELAXED);
/* Wake one waiter so recovery latency is not bounded by the 2s timeout. */
if (__atomic_load_n(&hdr->mutex_waiters, __ATOMIC_RELAXED) > 0)
view all matches for this distribution
view release on metacpan or search on metacpan
msgpack-3.3.0/README view on Meta::CPAN
msgpack_pack_true(&pk);
msgpack_pack_str(&pk, 7);
msgpack_pack_str_body(&pk, "example", 7);
/* deserialize the buffer into msgpack_object instance. */
/* deserialized object is valid during the msgpack_zone instance alive. */
msgpack_zone mempool;
msgpack_zone_init(&mempool, 2048);
msgpack_object deserialized;
msgpack_unpack(sbuf.data, sbuf.size, NULL, &mempool, &deserialized);
msgpack-3.3.0/README view on Meta::CPAN
std::string str(buffer.str());
msgpack::object_handle oh =
msgpack::unpack(str.data(), str.size());
// deserialized object is valid during the msgpack::object_handle instance is alive.
msgpack::object deserialized = oh.get();
// msgpack::object supports ostream.
std::cout << deserialized << std::endl;
view all matches for this distribution
view release on metacpan or search on metacpan
share/dictionary.txt view on Meta::CPAN
alike
alimentary
alimony
alimony's
alit
alive
alkali
alkali's
alkalies
alkaline
alkalinity
view all matches for this distribution