Skip Menu |

This queue is for tickets about the Net-GPSD3 CPAN distribution.

Report information
The Basics
Id: 117039
Status: new
Priority: 0/
Queue: Net-GPSD3

People
Owner: Nobody in particular
Requestors: raidlman [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Net::GPSD3 hanging on polls
Date: Thu, 18 Aug 2016 16:22:47 +0200
To: bug-Net-GPSD3 [...] rt.cpan.org
From: Stephan Riedel <raidlman [...] gmail.com>
Hi, recently I had a problem with hanging polls which ocured once in a while and blocked my whole application. I use the module in a thread to poll gpsd. Sig:SysAlarm's timeout_call and Time::Out's timeout weren't able to terminate the hanging socket->readline (anyway, using signals in threads is usually not a good idea...). So I changed the constructor of the GPSD3 socket to use the IO::Socket::Timeout module ( http://search.cpan.org/~dams/IO-Socket-Timeout-0.27/lib/IO/Socket/Timeout.pm). This is now working really reliable and should be done like that by default (imho). I'm on Debian 8 and use the repository packages. The latest source looks a little bit different but the same changes should work well. Best regards, Stephan sub socket { my $self = shift; unless ( defined( $self->{'socket'} ) and defined( $self->{'socket'}->connected ) ) { $self->{"socket"} = IO::Socket::INET6->new( PeerAddr => $self->host, PeerPort => $self->port, ); # enable and set timeouts for socket IO::Socket::Timeout->enable_timeouts_on($self->{"socket"}); $self->{"socket"}->read_timeout(0.5); $self->{"socket"}->write_timeout(0.5); die( sprintf( "Error: Cannot connect to gpsd://%s:%s/.\n", $self->host, $self->port ) ) unless defined( $self->{"socket"} ); } return $self->{'socket'}; }