diff options
author | Yves-Alexis Perez <corsac@debian.org> | 2018-06-04 09:59:21 +0200 |
---|---|---|
committer | Yves-Alexis Perez <corsac@debian.org> | 2018-06-04 09:59:21 +0200 |
commit | 51a71ee15c1bcf0e82f363a16898f571e211f9c3 (patch) | |
tree | 2a03e117d072c55cfe2863d26b73e64d933e7ad8 /src/libcharon/plugins/vici/perl | |
parent | 7793611ee71b576dd9c66dee327349fa64e38740 (diff) | |
download | vyos-strongswan-51a71ee15c1bcf0e82f363a16898f571e211f9c3.tar.gz vyos-strongswan-51a71ee15c1bcf0e82f363a16898f571e211f9c3.zip |
New upstream version 5.6.3
Diffstat (limited to 'src/libcharon/plugins/vici/perl')
-rw-r--r-- | src/libcharon/plugins/vici/perl/Vici-Session/lib/Vici/Transport.pm | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/libcharon/plugins/vici/perl/Vici-Session/lib/Vici/Transport.pm b/src/libcharon/plugins/vici/perl/Vici-Session/lib/Vici/Transport.pm index 6524bf76d..b0a7b6285 100644 --- a/src/libcharon/plugins/vici/perl/Vici-Session/lib/Vici/Transport.pm +++ b/src/libcharon/plugins/vici/perl/Vici-Session/lib/Vici/Transport.pm @@ -22,12 +22,27 @@ sub send { sub receive { my $self = shift; my $packet_header; - my $data; - $self->{'Socket'}->recv($packet_header, 4); + $packet_header = $self->_recv_all(4); my $packet_len = unpack('N', $packet_header); - $self->{'Socket'}->recv($data, $packet_len); - return $data; + return $self->_recv_all($packet_len); +} + +sub _recv_all { + my ($self, $len) = @_; + my $data; + + while ($len) + { + my $buf; + unless (defined $self->{'Socket'}->recv($buf, $len)) + { + die "error reading from socket\n"; + } + $len -= length($buf); + $data .= $buf; + } + return $data; } 1; |