lib_log: safeguard seq_nr

This commit is contained in:
Thomas Schoebel-Theuer 2013-01-04 22:11:22 +01:00
parent 2a809fddfd
commit 31374c81ab
1 changed files with 4 additions and 3 deletions

View File

@ -334,14 +334,13 @@ bool log_finalize(struct log_status *logst, int len, void (*endio)(void *private
DATA_PUT(data, offset, (char)1); // valid_flag copy DATA_PUT(data, offset, (char)1); // valid_flag copy
DATA_PUT(data, offset, (char)0); // spare DATA_PUT(data, offset, (char)0); // spare
DATA_PUT(data, offset, (short)0); // spare DATA_PUT(data, offset, (short)0); // spare
logst->seq_nr++; DATA_PUT(data, offset, logst->seq_nr + 1);
DATA_PUT(data, offset, logst->seq_nr);
get_lamport(&now); // when the log entry was ready. get_lamport(&now); // when the log entry was ready.
DATA_PUT(data, offset, now.tv_sec); DATA_PUT(data, offset, now.tv_sec);
DATA_PUT(data, offset, now.tv_nsec); DATA_PUT(data, offset, now.tv_nsec);
if (unlikely(offset > mref->ref_len)) { if (unlikely(offset > mref->ref_len)) {
MARS_ERR("length calculation was wrong: %d > %d\n", offset, mref->ref_len); MARS_FAT("length calculation was wrong: %d > %d\n", offset, mref->ref_len);
goto err; goto err;
} }
logst->offset = offset; logst->offset = offset;
@ -358,6 +357,8 @@ bool log_finalize(struct log_status *logst, int len, void (*endio)(void *private
cb_info->endios[nr_cb] = endio; cb_info->endios[nr_cb] = endio;
cb_info->privates[nr_cb] = private; cb_info->privates[nr_cb] = private;
// report success
logst->seq_nr++;
logst->count++; logst->count++;
ok = true; ok = true;