Skip to content

Commit

Permalink
clusterd: enable push to send symlink
Browse files Browse the repository at this point in the history
for the rolling upgrade we need to request another rpc version, because
the current receiver trusts the sender to send only plain files
  • Loading branch information
donald committed Jul 1, 2016
1 parent 6279419 commit 1f59127
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions clusterd/clusterd
Original file line number Diff line number Diff line change
Expand Up @@ -381,23 +381,32 @@ sub push_file {

my $st=Donald::FileInfo->lstat($filename);
defined $st or return warn "$filename: $!\n";
$st->type eq 'F' or die "$filename: not a plain file\n";
$st->size<=65536 or die "$filename: to big for broadcast (max 65536 bytes)\n";
my $rpc;
if ($st->type eq 'F') {
$rpc='filedata';
$st->size<=65536 or die "$filename: to big for broadcast (max 65536 bytes)\n";
if ($st->size==0) {
udp_broadcast_message($donald_s,$rpc,$st,0,'');
return;
}

if ($st->size==0) {
udp_broadcast_message($donald_s,'filedata',$st,0,'');
my $fh=new IO::File $filename,'<' or return warn "$filename: $!\n";
my $i=0;
for (my $pos=0;$pos<$st->size;$pos+=1024) {
my $data;
defined $fh->sysread($data,1024) or return warn "$filename: $!\n";
# warn "send bytes $pos to ",$pos+length($data),"\n";
udp_broadcast_message($donald_s,$rpc,$st,$pos,$data);
++$i % $BC_RATE or sleep 1;
}
} elsif ($st->type eq 'L') {
$rpc='filedata.2';
udp_broadcast_message($donald_s,$rpc,$st,0,'');
return;
} else {
die "file type not supported\n";
}

my $fh=new IO::File $filename,'<' or return warn "$filename: $!\n";
my $i=0;
for (my $pos=0;$pos<$st->size;$pos+=1024) {
my $data;
defined $fh->sysread($data,1024) or return warn "$filename: $!\n";
# warn "send bytes $pos to ",$pos+length($data),"\n";
udp_broadcast_message($donald_s,'filedata',$st,$pos,$data);
++$i % $BC_RATE or sleep 1;
}
}

our %CMD=(
Expand Down

0 comments on commit 1f59127

Please sign in to comment.