Mercurial > dovecot > original-hg > dovecot-1.2
comparison src/lib-storage/index/index-storage.c @ 3912:fc0b638330a4 HEAD
Added mbox_min_index_size setting.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 19 Jan 2006 01:14:43 +0200 |
parents | 411f20e72a8f |
children | cd701884900c |
comparison
equal
deleted
inserted
replaced
3911:3a2fe49912f3 | 3912:fc0b638330a4 |
---|---|
309 ibox->last_notify_type = MAILBOX_LOCK_NOTIFY_NONE; | 309 ibox->last_notify_type = MAILBOX_LOCK_NOTIFY_NONE; |
310 } | 310 } |
311 | 311 |
312 int index_storage_mailbox_init(struct index_mailbox *ibox, | 312 int index_storage_mailbox_init(struct index_mailbox *ibox, |
313 struct mail_index *index, const char *name, | 313 struct mail_index *index, const char *name, |
314 enum mailbox_open_flags flags) | 314 enum mailbox_open_flags flags, |
315 bool move_to_memory) | |
315 { | 316 { |
316 struct mail_storage *storage = &ibox->storage->storage; | 317 struct mail_storage *storage = &ibox->storage->storage; |
317 enum mail_index_open_flags index_flags; | 318 enum mail_index_open_flags index_flags; |
318 enum mail_index_lock_method lock_method = 0; | 319 enum mail_index_lock_method lock_method = 0; |
320 int ret; | |
319 | 321 |
320 i_assert(name != NULL); | 322 i_assert(name != NULL); |
321 | 323 |
322 ibox->box.storage = storage; | 324 ibox->box.storage = storage; |
323 ibox->box.name = p_strdup(ibox->box.pool, name); | 325 ibox->box.name = p_strdup(ibox->box.pool, name); |
324 array_create(&ibox->box.module_contexts, | 326 array_create(&ibox->box.module_contexts, |
325 ibox->box.pool, sizeof(void *), 5); | 327 ibox->box.pool, sizeof(void *), 5); |
326 | 328 |
327 index_flags = MAIL_INDEX_OPEN_FLAG_CREATE; | 329 index_flags = move_to_memory ? 0 : MAIL_INDEX_OPEN_FLAG_CREATE; |
328 if ((flags & MAILBOX_OPEN_FAST) != 0) | 330 if ((flags & MAILBOX_OPEN_FAST) != 0) |
329 index_flags |= MAIL_INDEX_OPEN_FLAG_FAST; | 331 index_flags |= MAIL_INDEX_OPEN_FLAG_FAST; |
330 if ((storage->flags & MAIL_STORAGE_FLAG_MMAP_DISABLE) != 0) | 332 if ((storage->flags & MAIL_STORAGE_FLAG_MMAP_DISABLE) != 0) |
331 index_flags |= MAIL_INDEX_OPEN_FLAG_MMAP_DISABLE; | 333 index_flags |= MAIL_INDEX_OPEN_FLAG_MMAP_DISABLE; |
332 #ifndef MMAP_CONFLICTS_WRITE | 334 #ifndef MMAP_CONFLICTS_WRITE |
353 ibox->next_lock_notify = time(NULL) + LOCK_NOTIFY_INTERVAL; | 355 ibox->next_lock_notify = time(NULL) + LOCK_NOTIFY_INTERVAL; |
354 ibox->commit_log_file_seq = 0; | 356 ibox->commit_log_file_seq = 0; |
355 ibox->mail_read_mmaped = (storage->flags & | 357 ibox->mail_read_mmaped = (storage->flags & |
356 MAIL_STORAGE_FLAG_MMAP_MAILS) != 0; | 358 MAIL_STORAGE_FLAG_MMAP_MAILS) != 0; |
357 | 359 |
358 if (mail_index_open(index, index_flags, lock_method) < 0) { | 360 ret = mail_index_open(index, index_flags, lock_method); |
359 mail_storage_set_index_error(ibox); | 361 if (ret <= 0 || move_to_memory) { |
360 index_storage_mailbox_free(&ibox->box); | 362 if (mail_index_move_to_memory(index) < 0) { |
361 return -1; | 363 /* try opening once more. it should be created |
364 directly into memory now. */ | |
365 ret = mail_index_open(index, index_flags, lock_method); | |
366 if (ret <= 0) { | |
367 mail_storage_set_index_error(ibox); | |
368 index_storage_mailbox_free(&ibox->box); | |
369 return -1; | |
370 } | |
371 } | |
362 } | 372 } |
363 | 373 |
364 ibox->md5hdr_ext_idx = | 374 ibox->md5hdr_ext_idx = |
365 mail_index_ext_register(index, "header-md5", 0, 16, 1); | 375 mail_index_ext_register(index, "header-md5", 0, 16, 1); |
366 | 376 |