pgbackrest.git / summary / log / commit / refs

commit    de35cedc277615bfb777f8a522d35a0d807de9dd
Author:   David Steele <david@pgmasters.net>
Date:     Sun Oct 05 22:52:05 2014 +0000

    Working on getting async process thread into Remote.pl


lib/BackRest/Remote.pm | 80 +++++++++++++++++++++++++++++++------------------- 1 file changed, 50 insertions(+), 30 deletions(-) diff --git a/lib/BackRest/Remote.pm b/lib/BackRest/Remote.pm index 414425f01..01196b046 100644 --- a/lib/BackRest/Remote.pm +++ b/lib/BackRest/Remote.pm @@ -127,6 +127,11 @@ sub DEMOLISH my $self = shift; $self->thread_kill(); + + if (defined($self->{oCompressAsync})) + { + $self->{oCompressAsync} = undef; + } } #################################################################################################################################### @@ -147,6 +152,21 @@ sub clone ); } +#################################################################################################################################### +# COMPRESS_ASYNC_GET +#################################################################################################################################### +sub compress_async_get +{ + my $self = shift; + + if (!defined($self->{oCompressAsync})) + { + $self->{oCompressAsync} = new BackRest::ProcessAsync; + } + + return $self->{oCompressAsync}; +} + #################################################################################################################################### # GREETING_READ # @@ -356,36 +376,36 @@ sub wait_pid # # De/Compresses data on a thread. #################################################################################################################################### -sub binary_xfer_thread -{ - my $self = shift; - - while (my $strMessage = $self->{oThreadQueue}->dequeue()) - { - my @stryMessage = split(':', $strMessage); - my @strHandle = split(',', $stryMessage[1]); - - my $hIn = IO::Handle->new_from_fd($strHandle[0], '<'); - my $hOut = IO::Handle->new_from_fd($strHandle[1], '>'); - - $self->{oThreadResult}->enqueue('running'); - - if ($stryMessage[0] eq 'compress') - { - gzip($hIn => $hOut) - or confess &log(ERROR, 'unable to compress: ' . $GzipError); - } - else - { - gunzip($hIn => $hOut) - or die confess &log(ERROR, 'unable to uncompress: ' . $GunzipError); - } - - close($hOut); - - $self->{oThreadResult}->enqueue('complete'); - } -} +# sub binary_xfer_thread +# { +# my $self = shift; +# +# while (my $strMessage = $self->{oThreadQueue}->dequeue()) +# { +# my @stryMessage = split(':', $strMessage); +# my @strHandle = split(',', $stryMessage[1]); +# +# my $hIn = IO::Handle->new_from_fd($strHandle[0], '<'); +# my $hOut = IO::Handle->new_from_fd($strHandle[1], '>'); +# +# $self->{oThreadResult}->enqueue('running'); +# +# if ($stryMessage[0] eq 'compress') +# { +# gzip($hIn => $hOut) +# or confess &log(ERROR, 'unable to compress: ' . $GzipError); +# } +# else +# { +# gunzip($hIn => $hOut) +# or die confess &log(ERROR, 'unable to uncompress: ' . $GunzipError); +# } +# +# close($hOut); +# +# $self->{oThreadResult}->enqueue('complete'); +# } +# } #################################################################################################################################### # BINARY_XFER [parent: 122dc65351f9]