Skip to content

Commit

Permalink
fs-randomfail: Set errno=EIO when random failure is triggered
Browse files Browse the repository at this point in the history
Previously the errno wasn't set at all. It was especially bad if it
happened to be EAGAIN, because that potentially caused hangs.
  • Loading branch information
sirainen committed Jun 21, 2017
1 parent 44c6d46 commit 05d1281
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/lib-fs/fs-randomfail.c
Expand Up @@ -238,6 +238,7 @@ static bool fs_random_fail(struct fs *_fs, int divider, enum fs_op op)
if (fs->op_probability[op] == 0)
return FALSE;
if ((unsigned int)(rand() % (100*divider)) <= fs->op_probability[op]) {
errno = EIO;
fs_set_error(_fs, RANDOMFAIL_ERROR);
return TRUE;
}
Expand Down

0 comments on commit 05d1281

Please sign in to comment.