struct mail_index_map *old_map, *new_map;
struct stat st;
uoff_t file_size;
- bool use_mmap, unusable = FALSE;
+ bool use_mmap, reopened, unusable = FALSE;
const char *error;
int ret, try;
*reason_r = NULL;
index->reopen_main_index = FALSE;
- ret = mail_index_reopen_if_changed(index, reason_r);
+ ret = mail_index_reopen_if_changed(index, &reopened, reason_r);
if (ret <= 0) {
if (ret < 0)
return -1;
int mail_index_try_open_only(struct mail_index *index);
void mail_index_close_file(struct mail_index *index);
-int mail_index_reopen_if_changed(struct mail_index *index,
+/* Returns 1 if index was successfully (re-)opened, 0 if the index no longer
+ exists, -1 if I/O error. If 1 is returned, reopened_r=TRUE if a new index
+ was actually reopened (or if index wasn't even open before this call). */
+int mail_index_reopen_if_changed(struct mail_index *index, bool *reopened_r,
const char **reason_r);
/* Update/rewrite the main index file from index->map */
void mail_index_write(struct mail_index *index, bool want_rotate,
}
}
-int mail_index_reopen_if_changed(struct mail_index *index,
+int mail_index_reopen_if_changed(struct mail_index *index, bool *reopened_r,
const char **reason_r)
{
struct stat st1, st2;
int ret;
+ *reopened_r = FALSE;
+
if (MAIL_INDEX_IS_IN_MEMORY(index)) {
*reason_r = "in-memory index";
return 0;
final:
if ((ret = mail_index_try_open_only(index)) == 0)
*reason_r = "index not found via open()";
- else if (ret > 0)
+ else if (ret > 0) {
*reason_r = "index opened";
+ *reopened_r = TRUE;
+ }
return ret;
}