static void imapc_mail_close(struct mail *_mail) { struct imapc_mail *mail = (struct imapc_mail *)_mail; struct imapc_mailbox *mbox = (struct imapc_mailbox *)_mail->box; struct imapc_mail_cache *cache = &mbox->prev_mail_cache; while (mail->fetch_count > 0) imapc_storage_run(mbox->storage); index_mail_close(_mail); if (mail->body_fetched) { imapc_mail_cache_free(cache); cache->uid = _mail->uid; if (cache->fd != -1) { cache->fd = mail->fd; mail->fd = -1; } else { cache->buf = mail->body; mail->body = NULL; } } if (mail->fd != -1) { if (close(mail->fd) < 0) i_error("close(imapc mail) failed: %m"); mail->fd = -1; } if (mail->body != NULL) buffer_free(&mail->body); }
static void imapc_mail_close(struct mail *_mail) { struct imapc_mail *mail = (struct imapc_mail *)_mail; struct imapc_mailbox *mbox = (struct imapc_mailbox *)_mail->box; struct imapc_mail_cache *cache = &mbox->prev_mail_cache; if (mail->fetch_count > 0) { imapc_mail_fetch_flush(mbox); while (mail->fetch_count > 0) imapc_mailbox_run_nofetch(mbox); } index_mail_close(_mail); mail->fetching_headers = NULL; if (mail->body_fetched) { imapc_mail_cache_free(cache); cache->uid = _mail->uid; if (cache->fd != -1) { cache->fd = mail->fd; mail->fd = -1; } else { cache->buf = mail->body; mail->body = NULL; } } if (mail->fd != -1) { if (close(mail->fd) < 0) i_error("close(imapc mail) failed: %m"); mail->fd = -1; } if (mail->body != NULL) buffer_free(&mail->body); mail->header_fetched = FALSE; mail->body_fetched = FALSE; }