mirror of
https://github.com/schoebel/mars
synced 2025-03-11 07:47:41 +00:00
light: fix use of wrong logfile after primary --force
This commit is contained in:
parent
fc436cf684
commit
2c8b72e5e3
@ -2391,6 +2391,32 @@ done:
|
||||
return status;
|
||||
}
|
||||
|
||||
static
|
||||
bool _next_is_acceptable(struct mars_rotate *rot, struct mars_dent *old_dent, struct mars_dent *new_dent)
|
||||
{
|
||||
/* Primaries are never allowed to consider logfiles not belonging to them.
|
||||
* Secondaries need this for replay, unfortunately.
|
||||
*/
|
||||
if ((rot->is_primary | rot->old_is_primary) ||
|
||||
(rot->trans_brick && rot->trans_brick->power.led_on && !rot->trans_brick->replay_mode)) {
|
||||
if (new_dent->new_stat.size) {
|
||||
MARS_WRN("logrotate impossible, '%s' size = %lld\n", new_dent->d_rest, new_dent->new_stat.size);
|
||||
return false;
|
||||
}
|
||||
if (strcmp(new_dent->d_rest, my_id())) {
|
||||
MARS_WRN("logrotate impossible, '%s'\n", new_dent->d_rest);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
/* Only secondaries should check for contiguity,
|
||||
* primaries sometimes need holes for emergency mode.
|
||||
*/
|
||||
if (new_dent->d_serial != old_dent->d_serial + 1)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Note: this is strictly called in d_serial order.
|
||||
* This is important!
|
||||
*/
|
||||
@ -2438,9 +2464,11 @@ int make_log_step(void *buf, struct mars_dent *dent)
|
||||
status = 0;
|
||||
if (rot->relevant_log) {
|
||||
if (!rot->next_relevant_log) {
|
||||
rot->next_relevant_log = dent;
|
||||
if (_next_is_acceptable(rot, rot->relevant_log, dent))
|
||||
rot->next_relevant_log = dent;
|
||||
} else if (!rot->next_next_relevant_log) {
|
||||
rot->next_next_relevant_log = dent;
|
||||
if (_next_is_acceptable(rot, rot->next_relevant_log, dent))
|
||||
rot->next_next_relevant_log = dent;
|
||||
}
|
||||
MARS_DBG("next_relevant_log = %p next_next_relevant_log = %p\n", rot->next_relevant_log, rot->next_next_relevant_log);
|
||||
goto ok;
|
||||
|
Loading…
Reference in New Issue
Block a user