AnyEvent

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

	- add a more explicit warning to AnyEvent::Handle that it doesn't
          work on files, people keep getting confused.
        - new function AnyEvent::Socket::tcp_bind.
        - new functions AnyEvent::fh_block and AnyEvent::fh_unblock.
	- aligned ipv6 address formatting with RFC 5952 (by not shortening
          a single :0: to ::).
        - added stability canary support.

7.09 Sat May  2 16:38:53 CEST 2015
	- AnyEvent::Debug called an internal function (AnyEvent::Log::ft)
          that was renamed to AnyEvent::Log:format_time. uinder its old name
          (analyzed by Michael Stovenour).
        - update AnyEvent::DNS fallback resolver addresses:
          seems google effectively killed most other free dns resolvers,
          so remove them, but add cable and wireless (ecrc) since it was
          stable for 20 years or so, official or not, and there should be
          an alternative to google.
        - perl5porters broke windows error codes in 5.20, and mapped
          WSAEWOULDBLOCK on the (different) EWOULDBLOCK error code, and
          WSAEINPROGRESS into the incompatible ERINPROGRESS code, probably
          because they were so cool. They probably broke other error codes

Changes  view on Meta::CPAN

          to fix them. This extreme step has been taken because the module actively
          attacks the goals of AnyEvent and makes it harder for module authors to use
          AnyEvent.

6.02  Fri Aug 26 20:08:31 CEST 2011
        - log_to_syslog now accepts facility strings.
	- log_to_syslog would not allow facilities - "$facility|$level"
          *literally* means that string. sheesh.
        - the CPAN parser got confused and thought we provide Sys::Syslog, try
          to work around.
        - renamed AnyEvent::Impl::FLTK2 to FLTK.

6.01  Fri Aug 26 07:04:11 CEST 2011
        - INCOMPATIBLE CHANGE: AnyEvent::DNS resource records now include
          the TTL as fourth element - this affects ->resolve, ->request
          and ->dns_unpack indirectly. Convenience functions such as
          AnyEvent::DNS::{a,txt,mx,srv} are not affected, neither is
          AnyEvent::Socket.
        - INCOMPATIBLE CHANGE: backend authors now should not implement
          one_event or loop, but instead the AnyEvent::CondVar::_wait and _poll
          methods.

Changes  view on Meta::CPAN

        - in the unlikely event of a virtual circuit connection
          being invalidated by a delayed udp reply, AnyEvent::DNS
          could die. this has been fixed.
        - plug a probable memleak in the DNS vc code.
        - use configured timeout also for VC request phase.
        - implement timeout and max_outstanding methods
          for resolver class.
        - update version numbers in all modules.

4.1  Thu May 29 05:45:40 CEST 2008
	- INCOMPATIBLE CHANGE: renamed xxx_ip functions to xxx_address
          which mirrors their purpose better (old names still available
          for a while). Also moved AnyEvent::DNS::addr to
          AnyEvent::Socket::resolve_sockaddr.
	- implement AnyEvent->time and AnyEvent->now.
        - fix IPv6 support in pack_sockaddr.
	- officially un-experimentalise all newly introduced code.
        - support unix domain sockets everywhere by specifying
          a host of "unix/" and the pathname as service.
        - implement an activity timeout in AnyEvent::Handle.
	- added a regex read type to AnyEvent::Handle.

Changes  view on Meta::CPAN

          such strong limits).
        - changed probe order to prefer coro adaptors.
        - explain why recursion into the event loop is not supported
          unless the backend supports it (only Coro::EV does without
          any restrictions...).
        - add simple manpages for all backend modules.

3.0  Mon Apr  7 21:30:23 CEST 2008
	- Coro::Signal changed semantics, roll our own, also cleaning
          up the Coro implementation in general.
        - rename Coro backend to CoroEvent.
        - add some decision helping paragraph to the manpage that should
          help people to decide whether AnyEvent is the right thing for them.

2.9  Mon Jan 28 13:31:54 CET 2008
	- update for EV 3.0 API changes.

2.8  Sun Nov 25 15:06:03 CET 2007
	- waitpid can validly return 0. accept this fact of life
          instead of reporting it to any watchers.

lib/AnyEvent/IO.pm  view on Meta::CPAN


package AnyEvent::IO;

use AnyEvent (); BEGIN { AnyEvent::common_sense }

use base "Exporter";

our @AIO_REQ = qw(
   aio_load aio_open aio_close aio_seek aio_read aio_write aio_truncate
   aio_utime aio_chown aio_chmod aio_stat aio_lstat
   aio_link aio_symlink aio_readlink aio_rename aio_unlink
   aio_mkdir aio_rmdir aio_readdir
);
*EXPORT = \@AIO_REQ;
our @FLAGS = qw(O_RDONLY O_WRONLY O_RDWR O_CREAT O_EXCL O_TRUNC O_APPEND);
*EXPORT_OK = \@FLAGS;
our %EXPORT_TAGS = (flags => \@FLAGS, aio => \@AIO_REQ);

our $MODEL;

if ($MODEL) {

lib/AnyEvent/IO.pm  view on Meta::CPAN

         or return AE::log warn => "/etc has low link count - non-POSIX filesystem?";

      print "/etc has ", (stat _)[3] - 2, " subdirectories.\n";
   };

=item aio_link $oldpath, $newpath, $cb->($success)

Calls C<link> on the paths and passes a true value to the callback on
success.

Example: link "F<file> to F<file.bak>, then rename F<file.new> over F<file>,
to atomically replace it.

   aio_link "file", "file.bak", sub {
      @_
         or return AE::log error => "file: $!";

      aio_rename "file.new", "file", sub {
         @_
            or return AE::log error => "file.new: $!";

         print "file atomically replaced by file.new, backup file.bak\n";
      };
   };

=item aio_symlink $oldpath, $newpath, $cb->($success)

Calls C<symlink> on the paths and passes a true value to the callback on

lib/AnyEvent/IO.pm  view on Meta::CPAN

Example: read the symlink called Fyslink> and verify that it contains "random data".

  aio_readlink "slink", sub {
     my ($target) = @_
        or return AE::log error => "slink: $!";

     $target eq "random data"
        or AE::log critical => "omg, the world will end!";
  };

=item aio_rename $oldpath, $newpath, $cb->($success)

Calls C<rename> on the paths and passes a true value to the callback on
success.

See C<aio_link> for an example.

=item aio_unlink $path, $cb->($success)

Tries to unlink the object at C<$path> and passes a true value to the
callback on success.

Example: try to delete the file F<tmpfile.dat~>.

lib/AnyEvent/IO/IOAIO.pm  view on Meta::CPAN

sub aio_symlink($$$) {
   my $cb = $_[2];
   IO::AIO::aio_symlink $_[0], $_[1],               sub { $cb->($_[0] ? () : 1) };
}

sub aio_readlink($$) {
   my $cb = $_[1];
   IO::AIO::aio_readlink $_[0],                     sub { $cb->(defined $_[0] ? $_[0] : ()) };
}

sub aio_rename($$$) {
   my $cb = $_[2];
   IO::AIO::aio_rename $_[0], $_[1],                sub { $cb->($_[0] ? () : 1) };
}

sub aio_unlink($$) {
   my $cb = $_[1];
   IO::AIO::aio_unlink $_[0],                       sub { $cb->($_[0] ? () : 1) };
}

sub aio_mkdir($$$) {
   my $cb = $_[2];
   IO::AIO::aio_mkdir $_[0], $_[1],                 sub { $cb->($_[0] ? () : 1) };

lib/AnyEvent/IO/Perl.pm  view on Meta::CPAN

   #TODO: raises an exception on !symlink systems, maybe eval + set errno?
   $_[2](symlink $_[0], $_[1] or ());
}

sub aio_readlink($$) {
   #TODO: raises an exception on !symlink systems, maybe eval + set errno?
   my $res = readlink $_[0];
   $_[1](defined $res ? $res : ());
}

sub aio_rename($$$) {
   $_[2](rename $_[0], $_[1] or ());
}

sub aio_unlink($$) {
   $_[1](unlink $_[0] or ());
}

sub aio_mkdir($$$) {
   $_[2](mkdir $_[0], $_[1] or ());
}

lib/AnyEvent/Log.pm  view on Meta::CPAN

(usually this logs to STDERR).

=item $ctx->log_to_file ($path)

Sets the C<log_cb> to log to a file (by appending), unbuffered. The
function might return before the log file has been opened or created.

=item $ctx->log_to_path ($path)

Same as C<< ->log_to_file >>, but opens the file for each message. This
is much slower, but allows you to change/move/rename/delete the file at
basically any time.

Needless(?) to say, if you do not want to be bitten by some evil person
calling C<chdir>, the path should be absolute. Doesn't help with
C<chroot>, but hey...

=item $ctx->log_to_syslog ([$facility])

Logs all messages via L<Sys::Syslog>, mapping C<trace> to C<debug> and
all the others in the obvious way. If specified, then the C<$facility> is

t/io_common  view on Meta::CPAN

print -s _ != 10 ? "not " : "", "ok ", $t++, " # stat size\n";

t 1, close => $fh;

t 1, stat => "$DIR/test";
print -s _ != 10 ? "not " : "", "ok ", $t++, " # stat size (", -s _,")\n";

t 1, lstat => "$DIR/test";
print -s _ != 10 ? "not " : "", "ok ", $t++, " # lstat size\n";

t 1, rename => "$DIR/test", "$DIR/test2";

#############################################################################
# test dir

t 0, readdir => "$DIR/nonexistent";
my $res = t 1, readdir => $DIR;
print @$res != 1           ? "not " : "", "ok ", $t++, " # res count\n";
print $res->[0] ne "test2" ? "not " : "", "ok ", $t++, " # res data (@$res)\n";

#############################################################################



( run in 0.619 second using v1.01-cache-2.11-cpan-131fc08a04b )