From 95330178b26b96232dddb188f82ad33da0d0b293 Mon Sep 17 00:00:00 2001 From: Steve Hay Date: Thu, 28 Jul 2016 14:22:16 +0100 Subject: Remove the default Net::Cmd::timeout() This accidentally overrode the timeout() in Net::FTP's $IOCLASS. Instead, we now document that timeout() needs to be provided by the Net::Cmd sub-class (normally by inheriting from IO::Socket::INET or similar (which in turn inherit from IO::Socket, which provides timeout()), which most users seem to do anyway). Similarly, document that close() most also be provided (normally by inheriting from IO::Handle, which IO::Socket::INET or similar also do, via IO::Socket). This fixes CPAN RT#116345. Thanks to ppisar@redhat.com for the analysis. --- Changes | 14 +++++++++++++- lib/Net/Cmd.pm | 17 +++++++---------- t/datasend.t | 2 ++ 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/Changes b/Changes index 1d574b7..d7d4cd8 100644 --- a/Changes +++ b/Changes @@ -2,7 +2,19 @@ Revision history for Perl distribution libnet 3.10 Development - - TODO + - Removed the default Net::Cmd::timeout() since it inadvertently overrode + the timeout() method in whatever IO::Socket::INET-like class sub-classes + of Net::Cmd also derive from (at least in cases where Net::Cmd takes + precedence in the method resolution, which it should do so that + Net::Cmd::getline() overrides IO::Handle::getline()). + + This does cause problems for any Net::Cmd sub-classes that don't provide + (by whatever means) the necessary parts of the interface of + IO::Socket::INET, but since they mostly seem to anyway (apart from the one + that led to the CPAN RT#110978 report!) this is now simply a documented + requirement. + + [CPAN RT#116345] 3.09 2016-07-19 diff --git a/lib/Net/Cmd.pm b/lib/Net/Cmd.pm index e739c89..38054c4 100644 --- a/lib/Net/Cmd.pm +++ b/lib/Net/Cmd.pm @@ -190,8 +190,6 @@ sub set_status { 1; } -sub timeout { 0 } - sub _syswrite_with_timeout { my $cmd = shift; my $line = shift; @@ -656,10 +654,15 @@ Net::Cmd - Network Command class (as used by FTP, SMTP etc) =head1 DESCRIPTION -C is a collection of methods that can be inherited by a sub class -of C. These methods implement the functionality required for a +C is a collection of methods that can be inherited by a sub-class +of C. These methods implement the functionality required for a command based protocol, for example FTP and SMTP. +If your sub-class does not also derive from C or similar (e.g. +C, C or C) then you must +provide the following methods by other means yourself: C and +C. + =head1 USER METHODS These methods provide a user interface to the C object. @@ -750,12 +753,6 @@ command server. Returns undef upon failure. -=item timeout () - -Returns the timeout value for this class, in seconds. The timeout provided -by the default implementation is 0; subclasses may override this if they -choose. - =item unsupported () Sets the status code to 580 and the response text to 'Unsupported command'. diff --git a/t/datasend.t b/t/datasend.t index 05903fb..0aea9d4 100644 --- a/t/datasend.t +++ b/t/datasend.t @@ -21,6 +21,8 @@ BEGIN { use Net::Cmd; our @ISA = qw(Net::Cmd IO::File); + sub timeout { 0 } + sub new { my $fh = shift->new_tmpfile; binmode($fh); -- cgit v1.2.3-24-ge0c7