It is apparently possible for drones to get into a state where their XMPP
socket is closed but they don't notice. This is bad because the drone can
continue to receive requests from its listener but can no longer respond
to them. To limit the pain this can cause, we should kill the drone as soon
as we notice this condition.
To avoid overhead, this commit notices when the socket returns an error (or
raises a signal, in Perl) upon write, and exits immediately. One message
will be lost, but the drone will no longer be a black hole that does nothing
but absorb requests it can never fill.
Signed-off-by: Mike Rylander <mrylander@gmail.com>
message_set_osrf_xid( t_msg, osrfLogGetXid() );
int retval = client_send_message( session->transport_handle, t_msg );
- if( retval )
- osrfLogError( OSRF_LOG_MARK, "client_send_message failed" );
+ if( retval ) {
+ osrfLogError( OSRF_LOG_MARK, "client_send_message failed, exit()ing immediately" );
+ exit(99);
+ }
osrfLogInfo(OSRF_LOG_MARK, "[%s] sent %d bytes of data to %s",
session->remote_service, strlen( payload ), t_msg->recipient );
# -----------------------------------------------------------
sub send {
my($self, $xml) = @_;
+
+ local $SIG{'PIPE'} = sub {
+ $logger->error("Disconnected from Jabber server, exiting immediately");
+ exit(99);
+ };
$self->{socket}->print($xml);
}