Date | Commit message (Collapse) |
|
This seems required to support COMPRESS DEFLATE in NNTP in the
next commit with minimal compatibility problems.
The only potential compatibility problem is existing users of
Net::NNTP won't be able to _blindly_ enable NNTP compression
without auditing their existing code for uses for
{syswrite,sysread}($cmd, ...).
Other options I've attempted or considered for NNTP COMPRESS,
but rejected:
* tie won't work for deflating, since we need to syswrite to
the original IO::Socket::* object (which may be IO::Socket::SSL)
once we have a buffer of deflated data.
* AFAIK, tie won't stack like PerlIO layers, either, and
IO::Socket::SSL already uses tie.
* using dup2 is wasteful, and won't work with TLS if we want
to keep $self stable
* open(my $fh, "<&=", $self) won't waste an FD, but still won't
work with TLS for the same reason.
* PerlIO::via won't work, since we rely on sysread/syswrite
and that bypasses IO layers.
So a future commit will provide ->syswrite and ->sysread to the
NNTP class once it's compressed, and we can rely on
SUPER::{sysread,syswrite} to make the underlying read, write, SSL_read,
or SSL_write calls.
|
|
sysread may call SSL_read, and SSL_read may buffer extra
data in userspace which can be returned via sysread without
making another read(2) syscall. This makes it it possible for
select() to block indefinitely since select() only knows about
buffers in the kernel, not userspace.
This problem was exposed by a forthcoming patch to support NNTP
compression, but it is theoretically possible to trigger with
use of TLS alone, especially if compression is done by the TLS
layer.
Fortunately for existing users, TLS compression isn't widely
used anymore because of CRIME and other vulnerabilities.
So, flip the socket to non-blocking, perform the sysread, using
select() to wait only if the kernel requires it, and reset the
original blocking state of the socket when done to maintain
compatibility with existing users.
Thread-safety with flipping the O_NONBLOCK flag like this should
not be a concern, because any application sharing connected TCP
sockets across threads is buggy, anyways.
|
|
sysread allow an offset argument to insert new data at a certain
place, use it to simplify our code, slightly.
|
|
|
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
Previuosly, subclasses were required to provide a timeout() function, but
this was not documented anywhere!
Fixes CPAN RT#110978.
|
|
|
|
|
|
|
|
Two other methods in Net::Cmd did syswrite() calls, both
without a loop or timeout. This replaces those with a call
to the new, common _syswrite_with_timeout() method, which
does both correctly and restarts after EINTR.
|
|
|
|
|
|
The data passed to datasend() should already be encoded, but it can
sometimes happen that the string holding the octets gets accidentally
upgraded and it was wrong for datasend() to treat it differently in
that case.
Fixes CPAN RT#104433. Many thanks to Ricardo and Aristotle for their help
on the ticket.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Bump that to 3.00 so that no $VERSIONs end up going backwards.
|
|
"Use of uninitialized value in join or string at lib/Net/Cmd.pm line 158."
|
|
Amongst other things, this fixes a problem of obsolete error codes being
returned after connection failure.
Patch by Tom Metro <tmetro@cpan.org> on CPAN RT#14875 with minor changes
by the committer to apply the patch to the current source.
|
|
|
|
|
|
|
|
|
|
|
|
|