Skip to content

Commit

Permalink
update receiver to handle symlinks
Browse files Browse the repository at this point in the history
symlinks need to be send to a new rpc "filedata.2" because the old rpc
can't handle it. the updated receiver is installed under the old name
"filedata" too in case older daemons send push
  • Loading branch information
donald committed Jul 1, 2016
1 parent 19eabd8 commit 83cf6d4
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions clusterd
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ our ($udp_peer_addr,$udp_peer_port); # ('141.14.12.12',1234)
our %UDP_HANDLER=
(
'filedata' => \&udp_rx_filedata,
'filedata.2' => \&udp_rx_filedata,
'amdtardata' => \&udp_rx_amdtardata,
'loadavg.2' => \&udp_rx_loadavg2,
'restart' => \&udp_rx_restart,
Expand Down Expand Up @@ -587,6 +588,24 @@ sub udp_rx_filedata {
return;
}

if ($st_want->type eq 'L') {
if (!$st_is || $st_is->type ne 'L' || $st_is->target ne $st_want->target) {
$st_is and (unlink($filename) or return warn "$filename: failed to unlink: $!\n");
symlink($st_want->target,$filename) or return warn "$filename: failed to create symlink: $!\n";
lchown($st_want->uid,$st_want->gid,$filename);
lmtime($st_want->mtime,$filename);
warn "installed $filename -> ".$st_want->target."\n";
} else {
if ($st_is->uid != $st_want->uid || $st_is->gid != $st_want->gid) {
lchown($st_want->uid,$st_want->gid,$filename);
}
if ($st_is->mtime != $st_want->mtime) {
lmtime($st_want->mtime,$filename);
}
}
return;
}

if (length($data) == $st_want->size) {
# complete file in one broadcast
my $fh=IO::File->new($tmp_filename,O_WRONLY|O_CREAT,0);
Expand Down

0 comments on commit 83cf6d4

Please sign in to comment.