[pve-devel] [PATCH ha-manager 05/10] more robust log read from child
Thomas Lamprecht
t.lamprecht at proxmox.com
Wed Dec 21 16:44:42 CET 2016
POSIX::read may be undefined on an error, check this.
There may be also more data available than we maximal read per call,
so call read until we read less than the maximum possible.
Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
src/PVE/HA/Sim/RTHardware.pm | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/PVE/HA/Sim/RTHardware.pm b/src/PVE/HA/Sim/RTHardware.pm
index f30a14a..8bdd9d0 100644
--- a/src/PVE/HA/Sim/RTHardware.pm
+++ b/src/PVE/HA/Sim/RTHardware.pm
@@ -167,8 +167,11 @@ sub fork_daemon {
my ($fd, $cond) = @_;
if ($cond eq 'in') {
my $readbuf;
- if (my $count = POSIX::read($fd, $readbuf, 8192)) {
- $self->append_text($readbuf);
+ while (1) {
+ my $count = POSIX::read($fd, $readbuf, 8192);
+ die "read error: $!\n" if !defined($count);
+ $self->append_text($readbuf) if $count > 0;
+ last if $count < 8192;
}
return 1;
} else {
--
2.1.4
More information about the pve-devel
mailing list