}
my $t_buf = "";
- my $read_size = 1024;
- my $f = 0;
+ my $read_size = 1024; my $f = 0;
while( my $n = sysread( $fh, $t_buf, $read_size ) ) {
+
+ unless( $fh->connected ) {
+ OpenSRF::EX::JabberDisconnected->throw(
+ "Lost jabber client in timed_read()");
+ }
+
$buffer .= $t_buf;
if( $n < $read_size ) {
#reset_fl( $fh, $f ) if $f;
$logger->transport( $self->{app} . " going into listen loop", INFO );
+
while(1) {
my $sock = $self->unix_sock();
- my $o = $self->process( -1 );
-
- if( ! defined( $o ) ) {
- throw OpenSRF::EX::Jabber( "Listen Loop failed at 'process()'" );
+ my $o;
+
+ try {
+ $o = $self->process( -1 );
+
+ } catch OpenSRF::EX::JabberDisconnected with {
+ $logger->error("Inbound process lost its ".
+ "jabber connection. Attempting to reconnect...");
+ $self->initialize;
+ };
+
+ if(defined $o) {
+ my $socket = IO::Socket::UNIX->new( Peer => $sock );
+ throw OpenSRF::EX::Socket( "Unable to connect to UnixServer: socket-file: $sock \n :=> $! " )
+ unless ($socket->connected);
+ print $socket $o;
+ $socket->close;
}
- my $socket = IO::Socket::UNIX->new( Peer => $sock );
- throw OpenSRF::EX::Socket( "Unable to connect to UnixServer: socket-file: $sock \n :=> $! " )
- unless ($socket->connected);
- print $socket $o;
- $socket->close;
-
}
throw OpenSRF::EX::Socket( "How did we get here?!?!" );