fix: check rotate_segment return value; use uint32_t for CRC fields
- In persist_wal_async(), check rotate_segment() return value and propagate -EIO on failure (MEDIUM)
- Change last_crc and last_replicated_crc fields from uint64_t to uint32_t to match CRC32 width (LOW)
Both fixes address code review issues in commit b0a5fbb.
This commit is contained in:
parent
b0a5fbb4e9
commit
1fe79ff934
2 changed files with 8 additions and 4 deletions
|
|
@ -256,8 +256,12 @@ int persist_wal_async(persist_t* p, uint32_t type,
|
|||
p->last_replicated_crc = hdr.crc;
|
||||
|
||||
/* Rotate segment when full */
|
||||
if (p->seg_offset >= WAL_SEGMENT_SIZE_BYTES)
|
||||
rotate_segment(p);
|
||||
if (p->seg_offset >= WAL_SEGMENT_SIZE_BYTES) {
|
||||
if (rotate_segment(p) != 0) {
|
||||
pthread_mutex_unlock(&p->lock);
|
||||
return -EIO;
|
||||
}
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&p->lock);
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -89,8 +89,8 @@ struct persist_s {
|
|||
/* WAL state */
|
||||
int wal_fd;
|
||||
uint64_t current_lsn;
|
||||
uint64_t last_crc;
|
||||
uint64_t last_replicated_crc;
|
||||
uint32_t last_crc;
|
||||
uint32_t last_replicated_crc;
|
||||
uint64_t term;
|
||||
uint32_t seg_offset;
|
||||
uint64_t checkpoint_lsn;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue