[dovecot-cvs] dovecot/src/lib-index mail-index.c, 1.226,
1.227 mail-transaction-log.c, 1.109, 1.110
cras at dovecot.org
cras at dovecot.org
Sun Feb 26 12:32:21 EET 2006
Update of /var/lib/cvs/dovecot/src/lib-index
In directory talvi:/tmp/cvs-serv27978/lib-index
Modified Files:
mail-index.c mail-transaction-log.c
Log Message:
If we reach the NFS_ESTALE_RETRY_COUNT, give an ESTALE error message as
well.
Index: mail-index.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index.c,v
retrieving revision 1.226
retrieving revision 1.227
diff -u -d -r1.226 -r1.227
--- mail-index.c 26 Feb 2006 10:15:41 -0000 1.226
+++ mail-index.c 26 Feb 2006 10:32:19 -0000 1.227
@@ -686,8 +686,9 @@
return ret;
}
-static int mail_index_read_map(struct mail_index *index,
- struct mail_index_map *map, bool *retry_r)
+static int
+mail_index_read_map(struct mail_index *index, struct mail_index_map *map,
+ bool *retry_r, bool try_retry)
{
const struct mail_index_header *hdr;
unsigned char buf[512];
@@ -753,7 +754,7 @@
}
if (ret < 0) {
- if (errno == ESTALE) {
+ if (errno == ESTALE && try_retry) {
/* a new index file was renamed over this one. */
*retry_r = TRUE;
return 0;
@@ -920,8 +921,9 @@
(*handlers[i])(index);
for (i = 0;; i++) {
- ret = mail_index_read_map(index, *map, &retry);
- if (ret != 0 || !retry || i == MAIL_INDEX_ESTALE_RETRY_COUNT)
+ ret = mail_index_read_map(index, *map, &retry,
+ i < MAIL_INDEX_ESTALE_RETRY_COUNT);
+ if (ret != 0 || !retry)
return ret;
/* ESTALE - reopen index file */
@@ -1083,7 +1085,7 @@
for (i = 0;; i++) {
ret = mail_index_read_header(index, hdr_r, sizeof(*hdr_r),
&pos);
- if (ret >= 0 || errno != ESTALE ||
+ if (ret <= 0 || errno != ESTALE ||
i == MAIL_INDEX_ESTALE_RETRY_COUNT)
break;
@@ -1102,6 +1104,9 @@
return -1;
}
}
+
+ if (ret < 0)
+ mail_index_set_syscall_error(index, "pread_full()");
return ret;
}
Index: mail-transaction-log.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-transaction-log.c,v
retrieving revision 1.109
retrieving revision 1.110
diff -u -d -r1.109 -r1.110
--- mail-transaction-log.c 26 Feb 2006 10:15:41 -0000 1.109
+++ mail-transaction-log.c 26 Feb 2006 10:32:19 -0000 1.110
@@ -354,7 +354,7 @@
static int
mail_transaction_log_file_read_hdr(struct mail_transaction_log_file *file,
- int head)
+ int head, bool ignore_estale)
{
struct mail_transaction_log_file *f;
int ret;
@@ -363,7 +363,7 @@
ret = pread_full(file->fd, &file->hdr, sizeof(file->hdr), 0);
if (ret < 0) {
- if (errno != ESTALE) {
+ if (errno != ESTALE || !ignore_estale) {
mail_index_file_set_syscall_error(file->log->index,
file->filepath,
"pread_full()");
@@ -642,7 +642,8 @@
static int
mail_transaction_log_file_fd_open(struct mail_transaction_log *log,
struct mail_transaction_log_file **file_r,
- const char *path, int fd, bool head)
+ const char *path, int fd, bool head,
+ bool ignore_estale)
{
struct mail_transaction_log_file *file;
struct stat st;
@@ -653,7 +654,7 @@
*file_r = NULL;
if (fstat(fd, &st) < 0) {
- if (errno != ESTALE) {
+ if (errno != ESTALE || !ignore_estale) {
mail_index_file_set_syscall_error(log->index, path,
"fstat()");
}
@@ -671,7 +672,7 @@
file->last_mtime = st.st_mtime;
file->last_size = st.st_size;
- ret = mail_transaction_log_file_read_hdr(file, head);
+ ret = mail_transaction_log_file_read_hdr(file, head, ignore_estale);
if (ret < 0) {
mail_transaction_log_file_free(file);
return -1;
@@ -685,7 +686,7 @@
static struct mail_transaction_log_file *
mail_transaction_log_file_fd_open_or_create(struct mail_transaction_log *log,
const char *path, int fd,
- bool *retry_r)
+ bool *retry_r, bool try_retry)
{
struct mail_transaction_log_file *file;
struct stat st;
@@ -693,9 +694,10 @@
*retry_r = FALSE;
- ret = mail_transaction_log_file_fd_open(log, &file, path, fd, TRUE);
+ ret = mail_transaction_log_file_fd_open(log, &file, path, fd, TRUE,
+ !try_retry);
if (ret < 0) {
- *retry_r = errno == ESTALE;
+ *retry_r = errno == ESTALE && try_retry;
return NULL;
}
@@ -724,11 +726,12 @@
file->last_size = st.st_size;
memset(&file->hdr, 0, sizeof(file->hdr));
- ret = mail_transaction_log_file_read_hdr(file, TRUE);
+ ret = mail_transaction_log_file_read_hdr(file, TRUE,
+ !try_retry);
}
}
if (ret <= 0) {
- *retry_r = errno == ESTALE;
+ *retry_r = errno == ESTALE && try_retry;
mail_transaction_log_file_free(file);
return NULL;
}
@@ -790,9 +793,8 @@
}
file = mail_transaction_log_file_fd_open_or_create(log, path,
- fd, &retry);
- if (file != NULL || !retry ||
- i == MAIL_INDEX_ESTALE_RETRY_COUNT)
+ fd, &retry, i == MAIL_INDEX_ESTALE_RETRY_COUNT);
+ if (file != NULL || !retry)
return file;
/* ESTALE - retry */
@@ -816,7 +818,7 @@
}
ret = mail_transaction_log_file_fd_open(log, &file, path,
- fd, TRUE);
+ fd, TRUE, i < MAIL_INDEX_ESTALE_RETRY_COUNT);
if (ret > 0)
break;
@@ -880,13 +882,9 @@
return -1;
file = mail_transaction_log_file_fd_open_or_create(log, path,
- fd, &retry);
+ fd, &retry, FALSE);
if (file == NULL) {
- if (retry) {
- mail_index_set_error(log->index,
- "%s: ESTALE unexpected while locked",
- path);
- }
+ i_assert(!retry);
return -1;
}
}
@@ -1007,7 +1005,8 @@
}
}
- ret = mail_transaction_log_file_fd_open(log, &file, path, fd, FALSE);
+ ret = mail_transaction_log_file_fd_open(log, &file, path, fd,
+ FALSE, TRUE);
if (ret <= 0) {
if (ret == 0) {
/* corrupted, delete it */
More information about the dovecot-cvs
mailing list