dovecot-2.0: lib-index: If .log file can't be opened read-write,...
dovecot at dovecot.org
dovecot at dovecot.org
Thu Apr 28 21:31:21 EEST 2011
details: http://hg.dovecot.org/dovecot-2.0/rev/5429f41aa6c1
changeset: 12757:5429f41aa6c1
user: Timo Sirainen <tss at iki.fi>
date: Thu Apr 28 21:30:21 2011 +0300
description:
lib-index: If .log file can't be opened read-write, fallback to read-only indexes.
diffstat:
src/lib-index/mail-transaction-log-file.c | 14 ++++++++++----
1 files changed, 10 insertions(+), 4 deletions(-)
diffs (39 lines):
diff -r dfd7df8cd214 -r 5429f41aa6c1 src/lib-index/mail-transaction-log-file.c
--- a/src/lib-index/mail-transaction-log-file.c Thu Apr 28 21:11:30 2011 +0300
+++ b/src/lib-index/mail-transaction-log-file.c Thu Apr 28 21:30:21 2011 +0300
@@ -760,13 +760,19 @@
int mail_transaction_log_file_open(struct mail_transaction_log_file *file,
bool check_existing)
{
+ struct mail_index *index = file->log->index;
unsigned int i;
bool ignore_estale;
int ret;
for (i = 0;; i++) {
- file->fd = nfs_safe_open(file->filepath, O_RDWR);
- if (file->fd == -1) {
+ file->fd = nfs_safe_open(file->filepath,
+ !index->readonly ? O_RDWR : O_RDONLY);
+ if (file->fd == -1 && errno == EACCES) {
+ file->fd = nfs_safe_open(file->filepath, O_RDONLY);
+ index->readonly = TRUE;
+ }
+ if (file->fd == -1) {
if (errno == ENOENT)
return 0;
@@ -790,11 +796,11 @@
if (ret == 0) {
/* corrupted */
- if (file->log->index->readonly) {
+ if (index->readonly) {
/* don't delete */
} else if (unlink(file->filepath) < 0 &&
errno != ENOENT) {
- mail_index_set_error(file->log->index,
+ mail_index_set_error(index,
"unlink(%s) failed: %m",
file->filepath);
}
More information about the dovecot-cvs
mailing list