diff --git a/doc/xml/release.xml b/doc/xml/release.xml
index 3d4aa84ad..4e9afd9cb 100644
--- a/doc/xml/release.xml
+++ b/doc/xml/release.xml
@@ -57,6 +57,10 @@
Simplify try..catch..finally names.
+
+
+ Inflate performance improvement for gzip filter.
+
@@ -78,6 +82,10 @@
Update Debian/Ubuntu containers to download latest version of pip.
+
+
+ Full unit test coverage for gzip filter.
+
diff --git a/lib/pgBackRest/Storage/Filter/Gzip.pm b/lib/pgBackRest/Storage/Filter/Gzip.pm
index 144b9efae..e5a1cd3b7 100644
--- a/lib/pgBackRest/Storage/Filter/Gzip.pm
+++ b/lib/pgBackRest/Storage/Filter/Gzip.pm
@@ -156,29 +156,26 @@ sub read
else
{
# If the local buffer size is not large enough to satisfy the request and there is still data to decompress
- if ($self->{lUncompressedBufferSize} < $iSize)
+ while ($self->{lUncompressedBufferSize} < $iSize && !$self->parent()->eof())
{
- while ($self->{lUncompressedBufferSize} < $iSize)
+ if (!defined($self->{tCompressedBuffer}) || length($self->{tCompressedBuffer}) == 0)
{
- if (!defined($self->{tCompressedBuffer}) || length($self->{tCompressedBuffer}) == 0)
- {
- $self->parent()->read(\$self->{tCompressedBuffer}, $self->{lCompressBufferMax});
- }
-
- my $iZLibStatus = $self->{oZLib}->inflate($self->{tCompressedBuffer}, $self->{tUncompressedBuffer});
- $self->{lUncompressedBufferSize} = length($self->{tUncompressedBuffer});
-
- last if $iZLibStatus == Z_STREAM_END;
-
- $self->errorCheck($iZLibStatus);
+ $self->parent()->read(\$self->{tCompressedBuffer}, $self->{lCompressBufferMax});
}
+
+ my $iZLibStatus = $self->{oZLib}->inflate($self->{tCompressedBuffer}, $self->{tUncompressedBuffer});
+ $self->{lUncompressedBufferSize} = length($self->{tUncompressedBuffer});
+
+ last if $iZLibStatus == Z_STREAM_END;
+
+ $self->errorCheck($iZLibStatus);
}
# Actual size is the lesser of the local buffer size or requested size - if the local buffer is smaller than the requested
# size it means that there was nothing more to be read
my $iActualSize = $self->{lUncompressedBufferSize} < $iSize ? $self->{lUncompressedBufferSize} : $iSize;
- # Append the to the request buffer
+ # Append to the request buffer
$$rtBuffer .= substr($self->{tUncompressedBuffer}, 0, $iActualSize);
# Truncate local buffer
@@ -206,7 +203,7 @@ sub write
$self->errorCheck($self->{oZLib}->deflate($$rtBuffer, $self->{tCompressedBuffer}));
# Only write when buffer is full
- if (defined($self->{tCompressedBuffer}) && length($self->{tCompressedBuffer}) > $self->{lCompressBufferMax})
+ if (length($self->{tCompressedBuffer}) > $self->{lCompressBufferMax})
{
$self->parent()->write(\$self->{tCompressedBuffer});
$self->{tCompressedBuffer} = undef;
@@ -260,6 +257,8 @@ sub close
# Close io
return $self->parent()->close();
}
+
+ return false;
}
1;
diff --git a/test/lib/pgBackRestTest/Common/DefineTest.pm b/test/lib/pgBackRestTest/Common/DefineTest.pm
index 3f3ea2ef5..266ea3d26 100644
--- a/test/lib/pgBackRestTest/Common/DefineTest.pm
+++ b/test/lib/pgBackRestTest/Common/DefineTest.pm
@@ -329,7 +329,7 @@ my $oTestDef =
&TESTDEF_COVERAGE =>
{
- 'Storage/Filter/Gzip' => TESTDEF_COVERAGE_PARTIAL,
+ 'Storage/Filter/Gzip' => TESTDEF_COVERAGE_FULL,
},
},
{
diff --git a/test/lib/pgBackRestTest/Module/Storage/StorageFilterGzipTest.pm b/test/lib/pgBackRestTest/Module/Storage/StorageFilterGzipTest.pm
index 11d8977e9..9e4aa895d 100644
--- a/test/lib/pgBackRestTest/Module/Storage/StorageFilterGzipTest.pm
+++ b/test/lib/pgBackRestTest/Module/Storage/StorageFilterGzipTest.pm
@@ -63,7 +63,8 @@ sub run
{
#---------------------------------------------------------------------------------------------------------------------------
my $oGzipIo = $self->testResult(
- sub {new pgBackRest::Storage::Filter::Gzip($oDriver->openWrite($strFileGz))}, '[object]', 'new write compress');
+ sub {new pgBackRest::Storage::Filter::Gzip($oDriver->openWrite($strFileGz), {lCompressBufferMax => 4})},
+ '[object]', 'new write compress');
my $tBuffer = substr($strFileContent, 0, 2);
$self->testResult(sub {$oGzipIo->write(\$tBuffer)}, 2, ' write 2 bytes');
@@ -125,6 +126,7 @@ sub run
$self->testResult(sub {$oGzipIo->read(\$tBuffer, 2)}, 0, ' read 0 bytes');
$self->testResult(sub {$oGzipIo->close()}, true, ' close');
+ $self->testResult(sub {$oGzipIo->close()}, false, ' close again');
$self->testResult($tBuffer, $strFileContent, ' check content');
storageTest()->remove($strFileGz);