Skip to content
Browse files

Report error to on_error callback.

Do not call destroy when handle is already undef'ed by on_error.
Support setting a different firehose server in eg/track.pl via FIREHOSE_SERVER
  • Loading branch information...
1 parent fcfc8a9 commit c02bcb88f5f5bedc79d0e0c5dcad0e1fcdeedbd4 @miyagawa miyagawa committed Mar 31, 2010
Showing with 7 additions and 3 deletions.
  1. +5 −1 eg/track.pl
  2. +2 −2 lib/AnyEvent/Twitter/Stream.pm
View
6 eg/track.pl
@@ -2,7 +2,11 @@
use strict;
use AnyEvent::Twitter::Stream;
-my $done = AnyEvent->condvar;
+if ($ENV{FIREHOSE_SERVER}) {
+ $AnyEvent::Twitter::Stream::STREAMING_SERVER = $ENV{FIREHOSE_SERVER};
+}
+
+my $done = AE::cv;
my($user, $password, $method, %args) = @ARGV;
View
4 lib/AnyEvent/Twitter/Stream.pm
@@ -99,7 +99,7 @@ sub new {
if ($handle) {
$handle->on_error(sub {
undef $handle;
- $on_error->(@_);
+ $on_error->($_[2]);
});
$handle->on_eof(sub {
undef $handle;
@@ -119,7 +119,7 @@ sub new {
$handle->push_read(line => $reader);
};
$handle->push_read(line => $reader);
- $self->{guard} = AnyEvent::Util::guard { $on_eof->(); $handle->destroy; undef $reader };
+ $self->{guard} = AnyEvent::Util::guard { $on_eof->(); $handle->destroy if $handle; undef $reader };
}
}
);

0 comments on commit c02bcb8

Please sign in to comment.
Something went wrong with that request. Please try again.