# New Ticket Created by  Paweł Pabian 
# Please include the string:  [perl #116288]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=116288 >


There was socket behavior change between Rakudo 2012.11 and 2012.12 that caused 
failure of many modules.

It is discussed here: https://github.com/parrot/parrot/issues/909

Current Perl 6 spec says that read($bytes) "Reads and returns $bytes bytes from 
the handle". But after change it returns only one chunk if desired $bytes count 
is higher than chunk size.

To reproduce:

* run following simple server that returns 2KB of data

perl6 -e 'my $listener = IO::Socket::INET.new( localhost => "", localport => 
8080, :listen ); while my $connection = $listener.accept( ) { $connection.send( 
"x" x 2048 ); $connection.close( ); }'

* and then try to read them

2012.11 is getting whole 2KB:
$ perl6 -e 'my $client = IO::Socket::INET.new( host => "localhost", port => 
8080 ); my $buf = $client.read(2048); $buf.bytes.say'
2048

while 2012.12 is getting only 256 bytes
$ perl6 -e 'my $client = IO::Socket::INET.new( host => "localhost", port => 
8080 ); my $buf = $client.read(2048); $buf.bytes.say'
256

Non-continous data flow is also broken:

* run following simple server that returns 8 bytes of data in 2 byte chunks

perl6 -e 'my $listener = IO::Socket::INET.new( localhost => "", localport => 
8080, :listen ); while my $connection = $listener.accept( ) { for ^4 { 
$connection.send( "xx" ); sleep 1;}; $connection.close( ); }'

2012.11 waits for desired amount of data to be available and returns 8 bytes

$ time perl6 -e 'my $client = IO::Socket::INET.new( host => "localhost", port 
=> 8080 ); my $buf = $client.read(8); $buf.bytes.say'
8
real    0m3.563s   # correct time, 3 sleeps were made before 8 bytes were 
available
user    0m0.417s
sys     0m0.135s

while 2012.12 gets only first batch available on socket

$ perl6 -e 'my $client = IO::Socket::INET.new( host => "localhost", port => 
8080 ); my $buf = $client.read(8); $buf.bytes.say'
2


Reply via email to