mirror of https://github.com/schoebel/mars
introduced allow-replay (independent from pause-sync)
This commit is contained in:
parent
6f5a3b0da2
commit
681ffcb35e
|
@ -1887,6 +1887,26 @@ int __update_all_links(struct mars_global *global, struct mars_dent *parent, str
|
|||
return status;
|
||||
}
|
||||
|
||||
static
|
||||
bool _check_allow_replay(struct mars_global *global, struct mars_dent *parent)
|
||||
{
|
||||
int res = false;
|
||||
char *path = path_make("%s/todo-%s/allow-replay", parent->d_path, my_id());
|
||||
struct mars_dent *allow_dent;
|
||||
|
||||
if (!path)
|
||||
goto done;
|
||||
allow_dent = mars_find_dent(global, path);
|
||||
if (!allow_dent || !allow_dent->new_link)
|
||||
goto done;
|
||||
sscanf(allow_dent->new_link, "%d", &res);
|
||||
MARS_DBG("'%s' -> %d\n", path, res);
|
||||
|
||||
done:
|
||||
brick_string_free(path);
|
||||
return res;
|
||||
}
|
||||
|
||||
static
|
||||
int make_log_finalize(struct mars_global *global, struct mars_dent *dent)
|
||||
{
|
||||
|
@ -1910,7 +1930,7 @@ int make_log_finalize(struct mars_global *global, struct mars_dent *dent)
|
|||
if (trans_brick->power.button && trans_brick->power.led_on && !trans_brick->power.led_off) {
|
||||
bool do_stop = true;
|
||||
if (trans_brick->do_replay) {
|
||||
do_stop = trans_brick->replay_code != 0;
|
||||
do_stop = trans_brick->replay_code != 0 || !_check_allow_replay(global, parent);
|
||||
} else {
|
||||
do_stop =
|
||||
!rot->is_primary ||
|
||||
|
@ -1947,7 +1967,8 @@ int make_log_finalize(struct mars_global *global, struct mars_dent *dent)
|
|||
goto done;
|
||||
}
|
||||
|
||||
do_start = (!rot->do_replay || rot->start_pos != rot->end_pos);
|
||||
do_start = (!rot->do_replay ||
|
||||
(rot->start_pos != rot->end_pos && _check_allow_replay(global, parent)));
|
||||
MARS_DBG("do_start = %d\n", (int)do_start);
|
||||
|
||||
if (do_start) {
|
||||
|
|
|
@ -338,6 +338,7 @@ sub create_res {
|
|||
symlink("1", "$todo/attach");
|
||||
symlink("0", "$todo/connect");
|
||||
symlink("1", "$todo/sync");
|
||||
symlink("1", "$todo/allow-replay");
|
||||
system("rm -f $tmp/syncstatus-$host");
|
||||
|
||||
if($create) {
|
||||
|
@ -384,9 +385,9 @@ sub attach_res {
|
|||
sub connect_res {
|
||||
my ($cmd, $res) = @_;
|
||||
my $disconnect = ($cmd eq "disconnect");
|
||||
my @paths = glob("$mars/resource-$res/todo-*/connect");
|
||||
my @paths = glob("$mars/resource-$res/todo-*/");
|
||||
for my $path (@paths) {
|
||||
_switch($cmd, $res, $path, !$disconnect);
|
||||
_switch($cmd, $res, "$path/connect", !$disconnect);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -397,33 +398,51 @@ sub connect_local_res {
|
|||
_switch($cmd, $res, $path, !$disconnect);
|
||||
}
|
||||
|
||||
sub pause_res {
|
||||
sub pause_sync_res {
|
||||
my ($cmd, $res) = @_;
|
||||
my $pause = ($cmd eq "pause-sync");
|
||||
my @paths = glob("$mars/resource-$res/todo-*/sync");
|
||||
my @paths = glob("$mars/resource-$res/todo-*/");
|
||||
for my $path (@paths) {
|
||||
_switch($cmd, $res, $path, !$pause);
|
||||
_switch($cmd, $res, "$path/sync", !$pause);
|
||||
}
|
||||
}
|
||||
|
||||
sub pause_local_res {
|
||||
sub pause_sync_local_res {
|
||||
my ($cmd, $res) = @_;
|
||||
my $pause = ($cmd eq "pause-sync-local");
|
||||
my $path = "$mars/resource-$res/todo-$host/sync";
|
||||
_switch($cmd, $res, $path, !$pause);
|
||||
}
|
||||
|
||||
sub pause_replay_res {
|
||||
my ($cmd, $res) = @_;
|
||||
my $pause = ($cmd eq "pause-replay");
|
||||
my @paths = glob("$mars/resource-$res/todo-*/");
|
||||
for my $path (@paths) {
|
||||
_switch($cmd, $res, "$path/allow-replay", !$pause);
|
||||
}
|
||||
}
|
||||
|
||||
sub pause_replay_local_res {
|
||||
my ($cmd, $res) = @_;
|
||||
my $pause = ($cmd eq "pause-sync-local");
|
||||
my $path = "$mars/resource-$res/todo-$host/allow-replay";
|
||||
_switch($cmd, $res, $path, !$pause);
|
||||
}
|
||||
|
||||
sub up_res {
|
||||
my ($cmd, $res) = @_;
|
||||
my $down = ($cmd eq "down");
|
||||
if($down) {
|
||||
pause_res("pause-sync", $res);
|
||||
pause_replay_res("pause-replay", $res);
|
||||
pause_sync_res("pause-sync", $res);
|
||||
connect_res("disconnect", $res);
|
||||
attach_res("detach", $res);
|
||||
} else {
|
||||
attach_res("attach", $res);
|
||||
connect_res("connect", $res);
|
||||
pause_res("resume-sync", $res);
|
||||
pause_sync_res("resume-sync", $res);
|
||||
pause_replay_res("resume-replay", $res);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -535,10 +554,14 @@ my %cmd_table =
|
|||
"status" => \&nyi_cmd,
|
||||
"dump" => \&senseless_cmd,
|
||||
"verify" => \&nyi_cmd,
|
||||
"pause-sync" => \&pause_res,
|
||||
"resume-sync" => \&pause_res,
|
||||
"pause-sync-local" => \&pause_local_res,
|
||||
"resume-sync-local" => \&pause_local_res,
|
||||
"pause-sync" => \&pause_sync_res,
|
||||
"resume-sync" => \&pause_sync_res,
|
||||
"pause-sync-local" => \&pause_sync_local_res,
|
||||
"resume-sync-local" => \&pause_sync_local_res,
|
||||
"pause-replay" => \&pause_replay_res,
|
||||
"resume-replay" => \&pause_replay_res,
|
||||
"pause-replay-local" => \&pause_replay_local_res,
|
||||
"resume-replay-local" => \&pause_replay_local_res,
|
||||
"new-current-uuid" => \&senseless_cmd,
|
||||
"dstate" => \&nyi_cmd,
|
||||
"hidden-commands" => \&ignore_cmd,
|
||||
|
|
Loading…
Reference in New Issue