]> git.proxmox.com Git - librados2-perl.git/commitdiff
allow clean shutdown with displaying 'partial read' error.
authorDietmar Maurer <dietmar@proxmox.com>
Tue, 21 Jan 2014 11:27:33 +0000 (12:27 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Tue, 21 Jan 2014 11:28:05 +0000 (12:28 +0100)
PVE/RADOS.pm

index c8044b7074ecbd8b3fe7264a6cacb0b341f60089..86c0df667683b424437006d2b7aca0bc37348f4e 100644 (file)
@@ -51,7 +51,7 @@ my $writedata = sub {
 };
 
 my $readdata = sub {
-    my ($fh) = @_;
+    my ($fh, $allow_eof) = @_;
 
     my $head = '';
 
@@ -60,6 +60,8 @@ my $readdata = sub {
     while (length($head) < 5) {
        last if !sysread $fh, $head, 5 - length($head), length($head);
     }
+    return undef if $allow_eof && length($head) == 0;
+
     die "partial read\n" if length($head) < 5;
     
     my ($cmd, $len) = unpack "a L", $head;
@@ -179,9 +181,9 @@ sub new {
        $self->{conn} = $conn;
 
        for (;;) {
-           my ($cmd, $data) = &$readdata($parent);
+           my ($cmd, $data) = &$readdata($parent, 1);
            
-           last if $cmd eq 'Q';
+           last if !$cmd || $cmd eq 'Q';
 
            my $res;
            eval {