diff options
author | Steve Hay <steve.m.hay@googlemail.com> | 2016-07-28 14:22:16 +0100 |
---|---|---|
committer | Steve Hay <steve.m.hay@googlemail.com> | 2016-07-28 14:22:16 +0100 |
commit | 95330178b26b96232dddb188f82ad33da0d0b293 (patch) | |
tree | 0e7337853e02f5fb59893db0e8322b9a51d7940e | |
parent | 41e46adcef382389085fdb979c5288b4ed2cf77c (diff) | |
download | perl-libnet-95330178b26b96232dddb188f82ad33da0d0b293.tar.gz |
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.
-rw-r--r-- | Changes | 14 | ||||
-rw-r--r-- | lib/Net/Cmd.pm | 17 | ||||
-rw-r--r-- | t/datasend.t | 2 |
3 files changed, 22 insertions, 11 deletions
@@ -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<Net::Cmd> is a collection of methods that can be inherited by a sub class -of C<IO::Handle>. These methods implement the functionality required for a +C<Net::Cmd> is a collection of methods that can be inherited by a sub-class +of C<IO::Socket::INET>. 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<IO::Socket::INET> or similar (e.g. +C<IO::Socket::IP>, C<IO::Socket::INET6> or C<IO::Socket::SSL>) then you must +provide the following methods by other means yourself: C<close()> and +C<timeout()>. + =head1 USER METHODS These methods provide a user interface to the C<Net::Cmd> 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); |