Mercurial > dovecot > original-hg > dovecot-1.2
changeset 7472:aa41caaf8e0b HEAD
If fcntl() fails with EACCES, give a more understandable error message since
it's more similar to EAGAIN than anything to do with permissions.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sun, 04 May 2008 02:53:55 +0300 |
parents | e7e3d6ffb0c1 |
children | 1b15881ed93b |
files | src/lib-storage/index/dbox/dbox-index.c src/lib-storage/index/mbox/mbox-lock.c src/lib/file-lock.c |
diffstat | 3 files changed, 19 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- 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 @@ 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 @@ 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;
--- 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 @@ /* 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; }
--- 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 @@ 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 @@ 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 }