dovecot-1.1: If fcntl() fails with EACCES, give a more understan...
dovecot at dovecot.org
dovecot at dovecot.org
Sun May 4 02:53:58 EEST 2008
details: http://hg.dovecot.org/dovecot-1.1/rev/aa41caaf8e0b
changeset: 7472:aa41caaf8e0b
user: Timo Sirainen <tss at iki.fi>
date: Sun May 04 02:53:55 2008 +0300
description:
If fcntl() fails with EACCES, give a more understandable error message since
it's more similar to EAGAIN than anything to do with permissions.
diffstat:
3 files changed, 19 insertions(+), 5 deletions(-)
src/lib-storage/index/dbox/dbox-index.c | 8 ++++++--
src/lib-storage/index/mbox/mbox-lock.c | 9 ++++++++-
src/lib/file-lock.c | 7 +++++--
diffs (72 lines):
diff -r e7e3d6ffb0c1 -r aa41caaf8e0b src/lib-storage/index/dbox/dbox-index.c
--- a/src/lib-storage/index/dbox/dbox-index.c Sun May 04 02:44:01 2008 +0300
+++ b/src/lib-storage/index/dbox/dbox-index.c Sun May 04 02:53:55 2008 +0300
@@ -346,6 +346,7 @@ dbox_index_lock_range(struct dbox_index
off_t start, off_t len)
{
struct flock fl;
+ const char *errstr;
fl.l_type = lock_type;
fl.l_whence = SEEK_SET;
@@ -355,9 +356,12 @@ dbox_index_lock_range(struct dbox_index
if ((errno == EACCES || errno == EAGAIN || errno == EINTR) &&
cmd == F_SETLK)
return 0;
+
+ errstr = errno != EACCES ? strerror(errno) :
+ "File is locked by another process (EACCES)";
mail_storage_set_critical(index->mbox->ibox.box.storage,
- "fcntl(%s, %s) failed: %m", index->path,
- lock_type == F_UNLCK ? "F_UNLCK" : "F_WRLCK");
+ "fcntl(%s, %s) failed: %s", index->path,
+ lock_type == F_UNLCK ? "F_UNLCK" : "F_WRLCK", errstr);
return -1;
}
return 1;
diff -r e7e3d6ffb0c1 -r aa41caaf8e0b src/lib-storage/index/mbox/mbox-lock.c
--- a/src/lib-storage/index/mbox/mbox-lock.c Sun May 04 02:44:01 2008 +0300
+++ b/src/lib-storage/index/mbox/mbox-lock.c Sun May 04 02:53:55 2008 +0300
@@ -533,8 +533,15 @@ static int mbox_lock_fcntl(struct mbox_l
/* non-blocking lock trying failed */
return 0;
}
- mbox_set_syscall_error(ctx->mbox, "fcntl()");
alarm(0);
+ if (errno != EACCES) {
+ mbox_set_syscall_error(ctx->mbox, "fcntl()");
+ return -1;
+ }
+ mail_storage_set_critical(&ctx->mbox->storage->storage,
+ "fcntl() failed with mbox file %s: "
+ "File is locked by another process (EACCES)",
+ ctx->mbox->path);
return -1;
}
diff -r e7e3d6ffb0c1 -r aa41caaf8e0b src/lib/file-lock.c
--- a/src/lib/file-lock.c Sun May 04 02:44:01 2008 +0300
+++ b/src/lib/file-lock.c Sun May 04 02:53:55 2008 +0300
@@ -39,6 +39,7 @@ static int file_lock_do(int fd, const ch
i_fatal("fcntl() locks not supported");
#else
struct flock fl;
+ const char *errstr;
fl.l_type = lock_type;
fl.l_whence = SEEK_SET;
@@ -64,10 +65,12 @@ static int file_lock_do(int fd, const ch
errno = EAGAIN;
return 0;
}
- i_error("fcntl(%s) locking failed for file %s: %m",
+ errstr = errno != EACCES ? strerror(errno) :
+ "File is locked by another process (EACCES)";
+ i_error("fcntl(%s) locking failed for file %s: %s",
lock_type == F_UNLCK ? "unlock" :
lock_type == F_RDLCK ? "read-lock" : "write-lock",
- path);
+ path, errstr);
return -1;
#endif
}
More information about the dovecot-cvs
mailing list