static int index_single_message(const char *mboxname, uint32_t uid) { int r; struct mailbox *mailbox = NULL; message_t *msg = NULL; int begun = 0; struct index_record record; r = mailbox_open_irl(mboxname, &mailbox); if (r) goto out; r = rx->begin_mailbox(rx, mailbox, SEARCH_UPDATE_INCREMENTAL); if (r) goto out; begun = 1; r = mailbox_find_index_record(mailbox, uid, &record); if (r) goto out; if (record.system_flags & (FLAG_EXPUNGED|FLAG_UNLINKED)) goto out; msg = message_new_from_record(mailbox, &record); if (!msg) goto out; if (rx->is_indexed(rx, msg)) goto out; if (verbose) fprintf(stderr, "squatter: indexing mailbox:%s uid:%u\n", mboxname, uid); r = index_getsearchtext(msg, rx, 0); out: if (begun) { int r2 = rx->end_mailbox(rx, mailbox); if (r2 && !r) r = r2; } message_unref(&msg); mailbox_close(&mailbox); return r; }
static int folder_message_unref(struct folder_ref_info * ref_info, mailmessage * msg) { struct message_ref_elt * msg_ref; int count; msg_ref = folder_info_get_msg_ref(ref_info, msg); if (msg_ref->ref_count == 0) { #ifdef ETPAN_APP_DEBUG ETPAN_APP_DEBUG((engine_app, "** BUG detected negative ref count !")); #endif } count = message_unref(msg_ref); if (count == 0) { folder_message_remove(ref_info, msg); mailmessage_free(msg); } return count; }
static inline int message_mime_unref(struct mailprivacy * privacy, struct message_ref_elt * ref_elt) { int count; message_unref(ref_elt); #ifdef LIBETPAN_REENTRANT pthread_mutex_lock(&ref_elt->lock); #endif ref_elt->mime_ref_count --; if (ref_elt->mime_ref_count == 0) mailprivacy_msg_flush(privacy, ref_elt->msg); count = ref_elt->mime_ref_count; #ifdef LIBETPAN_REENTRANT pthread_mutex_unlock(&ref_elt->lock); #endif return count; }