The chunk size adjustments introduced by the patches for bug
1709710
could result in calculating non-integral chunk sizes for Perl services.
This in turn led to fractional offsets and lengths being passed to
Perl's substr() function; rounding in turn can lead to characters
in the response getting silently dropped, which in turn broke
parsing the reconstituted response.
To test
-------
The problem can be reproduced by invoking
open-ils.storage open-ils.storage.actor.org_unit.descendants.atomic 1, 0
in Evergreen databases with org unit trees large enough that the
response gets chunked.
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Signed-off-by: Jason Stephenson <jason@sigio.com>
use Encode;
use base qw/Exporter OpenSRF/;
use Time::HiRes qw( time usleep );
+use POSIX ();
use warnings;
use strict;
my $chunk_size = $self->max_chunk_size;
if ($escaped_length > $self->max_chunk_size) {
- $chunk_size = ($raw_length / $escaped_length) * $self->max_chunk_size;
+ $chunk_size = POSIX::floor(($raw_length / $escaped_length) * $self->max_chunk_size);
}
if ($raw_length > $chunk_size) { # send partials ("chunking")