mail-index-alloc-cache.c (dovecot-2.3.16) | : | mail-index-alloc-cache.c (dovecot-2.3.17) | ||
---|---|---|---|---|
skipping to change at line 84 | skipping to change at line 84 | |||
i_assert(list->refcount == 0); | i_assert(list->refcount == 0); | |||
if (list->referenced) | if (list->referenced) | |||
mail_index_alloc_cache_list_unref(list); | mail_index_alloc_cache_list_unref(list); | |||
mail_index_free(&list->index); | mail_index_free(&list->index); | |||
i_free(list->mailbox_path); | i_free(list->mailbox_path); | |||
i_free(list); | i_free(list); | |||
} | } | |||
static struct mail_index_alloc_cache_list * | static struct mail_index_alloc_cache_list * | |||
mail_index_alloc_cache_find(const char *mailbox_path, const char *index_dir, | mail_index_alloc_cache_find_and_expire(const char *mailbox_path, | |||
const struct stat *index_st) | const char *index_dir, | |||
const struct stat *index_st) | ||||
{ | { | |||
struct mail_index_alloc_cache_list **indexp, *rec, *match; | struct mail_index_alloc_cache_list **indexp, *rec, *match; | |||
unsigned int destroy_count; | unsigned int destroy_count; | |||
struct stat st; | struct stat st; | |||
destroy_count = 0; match = NULL; | destroy_count = 0; match = NULL; | |||
for (indexp = &indexes; *indexp != NULL;) { | for (indexp = &indexes; *indexp != NULL;) { | |||
rec = *indexp; | rec = *indexp; | |||
if (match != NULL) { | if (match != NULL) { | |||
skipping to change at line 160 | skipping to change at line 161 | |||
if (errno == ENOENT) { | if (errno == ENOENT) { | |||
/* it'll be created later */ | /* it'll be created later */ | |||
} else if (errno == EACCES) { | } else if (errno == EACCES) { | |||
e_error(parent_event, "%s", | e_error(parent_event, "%s", | |||
eacces_error_get("stat", index_dir)); | eacces_error_get("stat", index_dir)); | |||
} else { | } else { | |||
e_error(parent_event, "stat(%s) failed: %m", index_dir); | e_error(parent_event, "stat(%s) failed: %m", index_dir); | |||
} | } | |||
} | } | |||
match = mail_index_alloc_cache_find(mailbox_path, index_dir, &st); | match = mail_index_alloc_cache_find_and_expire(mailbox_path, | |||
index_dir, &st); | ||||
if (match == NULL) { | if (match == NULL) { | |||
struct mail_index *index = | struct mail_index *index = | |||
mail_index_alloc(parent_event, index_dir, prefix); | mail_index_alloc(parent_event, index_dir, prefix); | |||
match = mail_index_alloc_cache_add(index, mailbox_path, &st); | match = mail_index_alloc_cache_add(index, mailbox_path, &st); | |||
} else { | } else { | |||
match->refcount++; | match->refcount++; | |||
} | } | |||
i_assert(match->index != NULL); | i_assert(match->index != NULL); | |||
return match->index; | return match->index; | |||
} | } | |||
struct mail_index * | ||||
mail_index_alloc_cache_find(const char *index_dir) | ||||
{ | ||||
struct mail_index_alloc_cache_list *rec; | ||||
struct stat st; | ||||
if (stat(index_dir, &st) < 0) { | ||||
if (errno != ENOENT) | ||||
i_error("stat(%s) failed: %m", index_dir); | ||||
return NULL; | ||||
} | ||||
for (rec = indexes; rec != NULL; rec = rec->next) { | ||||
if (st.st_ino == rec->index_dir_ino && | ||||
CMP_DEV_T(st.st_dev, rec->index_dir_dev)) | ||||
return rec->index; | ||||
} | ||||
return NULL; | ||||
} | ||||
static bool destroy_unrefed(unsigned int min_destroy_count) | static bool destroy_unrefed(unsigned int min_destroy_count) | |||
{ | { | |||
struct mail_index_alloc_cache_list **list, *rec; | struct mail_index_alloc_cache_list **list, *rec; | |||
bool destroyed = FALSE; | bool destroyed = FALSE; | |||
bool seen_ref0 = FALSE; | bool seen_ref0 = FALSE; | |||
for (list = &indexes; *list != NULL;) { | for (list = &indexes; *list != NULL;) { | |||
rec = *list; | rec = *list; | |||
if (rec->refcount == 0 && | if (rec->refcount == 0 && | |||
End of changes. 3 change blocks. | ||||
3 lines changed or deleted | 25 lines changed or added |