AnyEvent
view release on metacpan or search on metacpan
- support CAA records, based on patch by Steve Atkins.
- add freenom and cloudflare nameservers as dns fallback.
- AnyEvent::Strict would not properly ward against io watchers
on files when the handle passed was a file descriptor.
- document "internal" variables used by the dns en-/decoder to allow
enterprising users to extend them in a semi-official way.
7.14 Sat Jun 24 01:44:19 CEST 2017
- fix a crash bug in AnyEvent::Handle with openssl 1.1.0 (patched
by Paul Howarth and apparently tracked down by Mike McCauley).
- AnyEvent::Handle->keepalive was documented (and defined) twice
(found by Matt Merhar).
- AnyEvent::Socket::tcp_bind/tcp_server would immediately unlink a unix
listening socket unless a guard is used. Change this so that no
cleanup will be performed unless a guard is used and document this more
clearly.
- make tcp_bind/tcp_server error messages more regular.
- work around latest perl upstream breakage - this time, perl5porters were
apparently bullied by a bogus CVE (CVE-2016-1238), and since distros
stupidly apply anything that has "security fix" stamped on it, it's likely
going to be a problem in practise (and working around it is trivial on
- env variables can now be specified using AE_xyz instead of
PERL_ANYEVENT_xyz, subject to some rules.
- lots of new AnyEvent::Debug functionality.
- AnyEvent::Strict now checks for modifications of $_ by the callback
(by setting it to readonly while executing the callback, if possible).
- IO::Async sometimes cancels the wrong timer when you call cancel_timer.
Invest extra overhead to work around this peculiar behaviour.
- split the pure perl backend into a loop module and an impl
module (AnyEvent::Loop and AnyEvent::Impl::Perl).
- some read types (regex, netstring, json, storable) could
errornously keep an AE::Handle object alive on their own
(reported by Mohammad Toossi).
- AnyEvent::Socket::resolve_sockaddr and all functions using it now
supports /etc/hosts overrides.
- add more workarounds around child watcher bugs in IO::Async
and (newly introduced) in POE.
- use glib child watchers and try to work around its limitations,
if possible (based on a patch by Kevin Ryde).
- add support for FLTK (fltk2), via AnyEvent::Impl::FLTK2.
- many read types in AnyEvent::Handle would malfunction during
transitions to TLS because of a "delete $self->{rbuf}".
(reported by Torsten Foertsch).
- common::sense 2.0 could cause tcp_server to throw an exception
(analysed by elmex).
5.2 Mon Sep 14 07:04:49 CEST 2009
- INCOMPATIBLE CHANGE: do no longer support register_read_type
and register_write_type in AnyEvent::Handle, instead support
package names (the facility was mostly abused).
- implement "packagename-as-read/write type" support in
AnyEvent::Handle.
- AnyEvent::Handle: new options "keepalive" and "oobinline".
- oobinline set by default to avoid security issues.
- the pure-perl event loop backend wrongly detected times() fallback
support (spotted by Pavel Boldin).
5.12 Tue Sep 1 20:26:50 CEST 2009
- be more lenient when parsing resolv.conf files, as some people
use hashmarks as comment indicator inside directives (reported
by Michael S. Fischer).
- use same set of warnings as common::sense 2.0.
- fix a potential 32 bit overflow issue due to perl having problems
4.152 Sun Jun 22 14:15:44 CEST 2008
- allow for 32-bit perls that implement shifts differently
on different architectures in parse_ipv4 (reported and
analysed by Keiichi DAIBA).
4.151 Fri Jun 6 17:34:24 CEST 2008
- make sure specifying _only_ on_read and never pushing reads
works.
4.15 Fri Jun 6 13:00:46 CEST 2008
- the pure perl backend would keep some watchers alive when more than
one watcher was registered for the same fd.
- new "packstring" and "storable" read and write types
for AnyEvent::Handle.
- allow on_eof handler to be called after on_error with EPIPE returns.
- do not immediately call on_read callback in handle constructor.
4.14 Thu Jun 5 20:29:31 CEST 2008
- Fixed a bug in DNS SRV priority sorting.
- AnyEvent::Util::guard now reports runtime errors while
executing the guard block as warnings.
(still subject to change).
- take advantage of CLOCK_MONOTONIC, if available, in AnyEvent::Impl::Perl.
- provide AnyEvent::post_detect and @AnyEvent::post_detect, which
allows module authors to avoid forcing event loop detection.
(used by Coro::AIO, Coro::BDB, Coro::AnyEvent for example).
- remove coro backends: Coro now provides generic support for AnyEvent
via Coro::AnyEvent.
3.3 Mon Apr 28 09:51:06 CEST 2008
- added AnyEvent::Handle, AnyEvent::Socket and AnyEvent::Util modules.
- fix a bug in the pure perl backend that kept watchers alive
when multiple watchers were registered for the same fh/poll combo.
- add a benchmark section showing AnyEvent overhead and comparing
the different event loops with each other.
- prefer pure perl over tk when autoprobing, as it's about as fast,
but doesn't crash with many watchers.
- declare Qt support non-experimental.
- clarify the confusing section about the file descriptor being
kept alive.
- document the race between loading of an event module and
child processes exiting.
- support POE as "backend" (with some caveats, POE is not generic
enough, and darn slow).
- support Wx and Prima through POE.
- optimise perl backend to use 20% less memory and take advantage
of typical timeout behaviour. It can now compete with
select/poll-based C event loops in most cases (it is usually
faster than Event and Glib :).
- roughly cut EV memory use in half and increase its speed by 30%,
lib/AnyEvent.pm view on Meta::CPAN
#
# require AnyEvent::Util;
# my $guard = AnyEvent::Util::guard (sub {
# # "clean up"
# delete $LOGGER{$logger+0};
# });
#
# sub {
# return 0 unless $$renabled;
#
# $guard if 0; # keep guard alive, but don't cause runtime overhead
# require AnyEvent::Log unless $AnyEvent::Log::VERSION;
# package AnyEvent::Log;
# _log ($logger->[0], $level, @_) # logger->[0] has been converted at load time
# }
}
if (length $ENV{PERL_ANYEVENT_LOG}) {
require AnyEvent::Log; # AnyEvent::Log does the thing for us
}
lib/AnyEvent/Handle.pm view on Meta::CPAN
When doing small writes on sockets, your operating system kernel might
wait a bit for more data before actually sending it out. This is called
the Nagle algorithm, and usually it is beneficial.
In some situations you want as low a delay as possible, which can be
accomplishd by setting this option to a true value.
The default is your operating system's default behaviour (most likely
enabled). This option explicitly enables or disables it, if possible.
=item keepalive => <boolean>
Enables (default disable) the SO_KEEPALIVE option on the stream socket:
normally, TCP connections have no time-out once established, so TCP
connections, once established, can stay alive forever even when the other
side has long gone. TCP keepalives are a cheap way to take down long-lived
TCP connections when the other side becomes unreachable. While the default
is OS-dependent, TCP keepalives usually kick in after around two hours,
and, if the other side doesn't reply, take down the TCP connection some 10
to 15 minutes later.
It is harmless to specify this option for file handles that do not support
keepalives, and enabling it on connections that are potentially long-lived
is usually a good idea.
=item oobinline => <boolean>
BSD majorly fucked up the implementation of TCP urgent data. The result
is that almost no OS implements TCP according to the specs, and every OS
implements it slightly differently.
If you want to handle TCP urgent data, then setting this flag (the default
is enabled) gives you the most portable way of getting urgent data, by
lib/AnyEvent/Handle.pm view on Meta::CPAN
$self->{read_size} ||= 2048;
$self->{max_read_size} = $self->{read_size}
if $self->{read_size} > ($self->{max_read_size} || MAX_READ_SIZE);
$self->timeout (delete $self->{timeout} ) if $self->{timeout};
$self->rtimeout (delete $self->{rtimeout} ) if $self->{rtimeout};
$self->wtimeout (delete $self->{wtimeout} ) if $self->{wtimeout};
$self->no_delay (delete $self->{no_delay} ) if exists $self->{no_delay} && $self->{no_delay};
$self->keepalive (delete $self->{keepalive}) if exists $self->{keepalive} && $self->{keepalive};
$self->oobinline (exists $self->{oobinline} ? delete $self->{oobinline} : 1);
$self->starttls (delete $self->{tls}, delete $self->{tls_ctx})
if $self->{tls};
$self->on_drain (delete $self->{on_drain} ) if $self->{on_drain};
$self->start_read
if $self->{on_read} || @{ $self->{_queue} };
lib/AnyEvent/Handle.pm view on Meta::CPAN
=cut
sub no_delay {
$_[0]{no_delay} = $_[1];
setsockopt $_[0]{fh}, Socket::IPPROTO_TCP (), Socket::TCP_NODELAY (), int $_[1]
if $_[0]{fh};
}
=item $handle->keepalive ($boolean)
Enables or disables the C<keepalive> setting (see constructor argument of
the same name for details).
=cut
sub keepalive {
$_[0]{keepalive} = $_[1];
eval {
local $SIG{__DIE__};
setsockopt $_[0]{fh}, Socket::SOL_SOCKET (), Socket::SO_KEEPALIVE (), int $_[1]
if $_[0]{fh};
};
}
=item $handle->oobinline ($boolean)
lib/AnyEvent/Intro.pod view on Meta::CPAN
poll => "r",
There is a trick here, however: the read watcher isn't stored in a global
variable, but in a local one - if the callback returns, it would normally
destroy the variable and its contents, which would in turn unregister our
watcher.
To avoid that, we refer to the watcher variable in the watcher callback.
This means that, when the C<tcp_connect> callback returns, perl thinks
(quite correctly) that the read watcher is still in use - namely inside
the inner callback - and thus keeps it alive even if nothing else in the
program refers to it anymore (it is much like Baron Münchhausen keeping
himself from dying by pulling himself out of a swamp).
The trick, however, is that instead of:
my $read_watcher = AnyEvent->io (...
The program does:
my $read_watcher; $read_watcher = AnyEvent->io (...
lib/AnyEvent/Log.pm view on Meta::CPAN
logging - when the C<logger> function is called once, but the returned
logger callback often, then this can be a tremendous speed win.
Despite this speed advantage, changes in logging configuration will
still be reflected by the logger callback, even if configuration changes
I<after> it was created.
To further speed up logging, you can bind a scalar variable to the logger,
which contains true if the logger should be called or not - if it is
false, calling the logger can be safely skipped. This variable will be
updated as long as C<$logger> is alive.
Full example:
# near the init section
use AnyEvent::Log;
my $debug_log = AnyEvent:Log::logger debug => \my $debug;
# and later in your program
$debug_log->("yo, stuff here") if $debug;
lib/AnyEvent/Log.pm view on Meta::CPAN
_reassess $logger+0;
require AnyEvent::Util unless $AnyEvent::Util::VERSION;
my $guard = AnyEvent::Util::guard (sub {
# "clean up"
delete $LOGGER{$logger+0};
});
sub {
$guard if 0; # keep guard alive, but don't cause runtime overhead
_log $ctx, $level, @_
if $$renabled;
}
}
sub logger($;$) {
_logger
$CTX{ (caller)[0] } ||= _pkg_ctx +(caller)[0],
@_
lib/AnyEvent/Socket.pm view on Meta::CPAN
mode) as first, and the peer host and port as second and third arguments
(see C<tcp_connect> for details).
Croaks on any errors it can detect before the listen.
In non-void context, this function returns a guard object whose lifetime
it tied to the TCP server: If the object gets destroyed, the server will
be stopped and the listening socket will be cleaned up/unlinked (already
accepted connections will not be affected).
When called in void-context, AnyEvent will keep the listening socket alive
internally. In this case, there is no guarantee that the listening socket
will be cleaned up or unlinked.
In all cases, when the function returns to the caller, the socket is bound
and in listening state.
If you need more control over the listening socket, you can provide a
C<< $prepare_cb->($fh, $host, $port) >>, which is called just before the
C<listen ()> call, with the listen file handle as first argument, and IP
address and port number of the local socket endpoint as second and third
lib/AnyEvent/Socket.pm view on Meta::CPAN
}, $prepare
}
sub tcp_server($$$;$) {
my ($host, $service, $accept, $prepare) = @_;
_tcp_bind $host, $service, sub {
my $rstate = shift;
$rstate->{aw} = AE::io $rstate->{fh}, 0, sub {
# this closure keeps $state alive
while ($rstate->{fh} && (my $peer = accept my $fh, $rstate->{fh})) {
AnyEvent::fh_unblock $fh; # POSIX requires inheritance, the outside world does not
my ($service, $host) = unpack_sockaddr $peer;
$accept->($fh, format_address $host, $service);
}
};
}, $prepare
}
( run in 1.813 second using v1.01-cache-2.11-cpan-df04353d9ac )