mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 02:49:02 -04:00
Avoid to close invalid handle
This could happen if open() return -1.
This commit is contained in:
parent
ef6958b410
commit
0b4aee793a
1 changed files with 6 additions and 2 deletions
|
|
@ -201,7 +201,6 @@ int parity_create(struct snapraid_parity_handle* handle, const struct snapraid_p
|
|||
split->f = -1;
|
||||
split->size = parity->split_map[s].size;
|
||||
split->limit_size = PARITY_LIMIT(limit_size, s, level);
|
||||
++handle->split_mac;
|
||||
|
||||
/* opening in sequential mode in Windows */
|
||||
flags = O_RDWR | O_CREAT | O_BINARY | advise_flags(&split->advise);
|
||||
|
|
@ -213,6 +212,9 @@ int parity_create(struct snapraid_parity_handle* handle, const struct snapraid_p
|
|||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
/* we have a valid file handle */
|
||||
++handle->split_mac;
|
||||
|
||||
/* get the stat info */
|
||||
ret = fstat(split->f, &split->st);
|
||||
if (ret != 0) {
|
||||
|
|
@ -558,7 +560,6 @@ int parity_open(struct snapraid_parity_handle* handle, const struct snapraid_par
|
|||
split->f = -1;
|
||||
split->size = parity->split_map[s].size;
|
||||
split->limit_size = PARITY_LIMIT(limit_size, s, level);
|
||||
++handle->split_mac;
|
||||
|
||||
/* open for read */
|
||||
/* O_NOATIME: do not change access time */
|
||||
|
|
@ -570,6 +571,9 @@ int parity_open(struct snapraid_parity_handle* handle, const struct snapraid_par
|
|||
goto bail;
|
||||
}
|
||||
|
||||
/* we have a valid file handle */
|
||||
++handle->split_mac;
|
||||
|
||||
/* get the stat info */
|
||||
ret = fstat(split->f, &split->st);
|
||||
if (ret != 0) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue