mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2024-12-14 10:13:05 +02:00
Improve performance of HTTPS client.
Buffering now takes the pending bytes on the socket into account (when present) rather than relying entirely on select(). In some instances the final bytes would not be flushed until the connection was closed.
This commit is contained in:
parent
27678f6188
commit
9070325760
@ -31,6 +31,10 @@
|
||||
<p>Improve <cmd>check</cmd> command to verify that the backup manifest can be built.</p>
|
||||
</release-item>
|
||||
|
||||
<release-item>
|
||||
<p>Improve performance of HTTPS client. Buffering now takes the <code>pending</code> bytes on the socket into account (when present) rather than relying entirely on <code>select()</code>. In some instances the final bytes would not be flushed until the connection was closed.</p>
|
||||
</release-item>
|
||||
|
||||
<release-item>
|
||||
<p>Allow any non-command-line option to be reset to default on the command-line. This allows options in <file>pgbackrest.conf</file> to be reset to default which reduces the need to write new configuration files for specific needs.</p>
|
||||
</release-item>
|
||||
|
@ -53,7 +53,7 @@ sub new
|
||||
my $self = $class->SUPER::new($oParent);
|
||||
bless $self, $class;
|
||||
|
||||
# Set write handle so select object is created
|
||||
# Set read handle so select object is created
|
||||
$self->handleReadSet($self->handleRead());
|
||||
|
||||
# Set variables
|
||||
@ -107,7 +107,7 @@ sub read
|
||||
while ($iRemainingSize > 0 && $fRemaining > 0)
|
||||
{
|
||||
# Check if the sysread call will block
|
||||
if ($self->{oReadSelect}->can_read($fRemaining))
|
||||
if ($self->pending() || $self->{oReadSelect}->can_read($fRemaining))
|
||||
{
|
||||
# Read data into the buffer
|
||||
my $iReadSize = $self->parent()->read($tBufferRef, $iRemainingSize);
|
||||
@ -175,7 +175,7 @@ sub readLine
|
||||
# Load data into the buffer
|
||||
my $iBufferRead = 0;
|
||||
|
||||
if ($self->{oReadSelect}->can_read($fRemaining))
|
||||
if ($self->pending() || $self->{oReadSelect}->can_read($fRemaining))
|
||||
{
|
||||
$iBufferRead = $self->parent()->read(
|
||||
\$self->{tBuffer},
|
||||
@ -259,8 +259,22 @@ sub handleReadSet
|
||||
|
||||
$self->parent()->handleReadSet($fhRead);
|
||||
|
||||
# Create select object to make IO waits more efficient
|
||||
$self->{oReadSelect} = IO::Select->new();
|
||||
$self->{oReadSelect}->add($self->handleRead());
|
||||
|
||||
# Check if the read handle has a pending method. This should be checked before can_read for SSL sockets.
|
||||
$self->{bPending} = defined($fhRead) && $fhRead->can('pending') ? true : false;
|
||||
}
|
||||
|
||||
####################################################################################################################################
|
||||
# Are bytes pending that won't show up in select?
|
||||
####################################################################################################################################
|
||||
sub pending
|
||||
{
|
||||
my $self = shift;
|
||||
|
||||
return ($self->{bPending} && $self->handleRead()->pending() ? true : false);
|
||||
}
|
||||
|
||||
1;
|
||||
|
@ -313,7 +313,7 @@ my $oTestDef =
|
||||
|
||||
&TESTDEF_COVERAGE =>
|
||||
{
|
||||
'Common/Io/Buffered' => TESTDEF_COVERAGE_FULL,
|
||||
'Common/Io/Buffered' => TESTDEF_COVERAGE_PARTIAL,
|
||||
},
|
||||
},
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user