]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
fs-randomfail: Set errno=EIO when random failure is triggered
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 21 Jun 2017 10:10:19 +0000 (13:10 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 21 Jun 2017 10:10:19 +0000 (13:10 +0300)
Previously the errno wasn't set at all. It was especially bad if it
happened to be EAGAIN, because that potentially caused hangs.

src/lib-fs/fs-randomfail.c

index 862783eddd9ad9148ac384241843d2d5aa0f7df8..563e8603d5763b88c43ff88e6262d0aee4fd9033 100644 (file)
@@ -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;
        }