ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent/lib/AnyEvent/Handle.pm
(Generate patch)

Comparing AnyEvent/lib/AnyEvent/Handle.pm (file contents):
Revision 1.154 by root, Sat Jul 18 05:19:09 2009 UTC vs.
Revision 1.157 by root, Wed Jul 22 23:07:13 2009 UTC

11 11
12AnyEvent::Handle - non-blocking I/O on file handles via AnyEvent 12AnyEvent::Handle - non-blocking I/O on file handles via AnyEvent
13 13
14=cut 14=cut
15 15
16our $VERSION = 4.85; 16our $VERSION = 4.86;
17 17
18=head1 SYNOPSIS 18=head1 SYNOPSIS
19 19
20 use AnyEvent; 20 use AnyEvent;
21 use AnyEvent::Handle; 21 use AnyEvent::Handle;
1519 1519
1520Instead of starting TLS negotiation immediately when the AnyEvent::Handle 1520Instead of starting TLS negotiation immediately when the AnyEvent::Handle
1521object is created, you can also do that at a later time by calling 1521object is created, you can also do that at a later time by calling
1522C<starttls>. 1522C<starttls>.
1523 1523
1524Starting TLS is currently an asynchronous operation - when you push some
1525write data and then call C<< ->starttls >> then TLS negotiation will start
1526immediately, after which the queued write data is then sent.
1527
1524The first argument is the same as the C<tls> constructor argument (either 1528The first argument is the same as the C<tls> constructor argument (either
1525C<"connect">, C<"accept"> or an existing Net::SSLeay object). 1529C<"connect">, C<"accept"> or an existing Net::SSLeay object).
1526 1530
1527The second argument is the optional C<AnyEvent::TLS> object that is used 1531The second argument is the optional C<AnyEvent::TLS> object that is used
1528when AnyEvent::Handle has to create its own TLS connection object, or 1532when AnyEvent::Handle has to create its own TLS connection object, or
1552 $ERROR_SYSCALL = Net::SSLeay::ERROR_SYSCALL (); 1556 $ERROR_SYSCALL = Net::SSLeay::ERROR_SYSCALL ();
1553 $ERROR_WANT_READ = Net::SSLeay::ERROR_WANT_READ (); 1557 $ERROR_WANT_READ = Net::SSLeay::ERROR_WANT_READ ();
1554 1558
1555 $ctx ||= $self->{tls_ctx}; 1559 $ctx ||= $self->{tls_ctx};
1556 1560
1561 local $Carp::CarpLevel = 1; # skip ourselves when creating a new context or session
1562
1557 if ("HASH" eq ref $ctx) { 1563 if ("HASH" eq ref $ctx) {
1558 require AnyEvent::TLS; 1564 require AnyEvent::TLS;
1559
1560 local $Carp::CarpLevel = 1; # skip ourselves when creating a new context
1561 1565
1562 if ($ctx->{cache}) { 1566 if ($ctx->{cache}) {
1563 my $key = $ctx+0; 1567 my $key = $ctx+0;
1564 $ctx = $TLS_CACHE{$key} ||= new AnyEvent::TLS %$ctx; 1568 $ctx = $TLS_CACHE{$key} ||= new AnyEvent::TLS %$ctx;
1565 } else { 1569 } else {
1637 1641
1638 &_freetls; 1642 &_freetls;
1639 1643
1640 my $linger = exists $self->{linger} ? $self->{linger} : 3600; 1644 my $linger = exists $self->{linger} ? $self->{linger} : 3600;
1641 1645
1642 if ($linger && length $self->{wbuf}) { 1646 if ($linger && length $self->{wbuf} && $self->{fh}) {
1643 my $fh = delete $self->{fh}; 1647 my $fh = delete $self->{fh};
1644 my $wbuf = delete $self->{wbuf}; 1648 my $wbuf = delete $self->{wbuf};
1645 1649
1646 my @linger; 1650 my @linger;
1647 1651

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines