void mail_cache_expunge_count(struct mail_cache *cache, unsigned int count) { if (mail_cache_lock(cache) > 0) { cache->hdr_copy.deleted_record_count += count; if (cache->hdr_copy.record_count >= count) cache->hdr_copy.record_count -= count; else cache->hdr_copy.record_count = 0; cache->hdr_modified = TRUE; (void)mail_cache_unlock(cache); } }
static int mail_cache_handler_lock(struct mail_cache_sync_context *ctx, struct mail_cache *cache) { int ret; if (ctx->locked) return MAIL_CACHE_IS_UNUSABLE(cache) ? 0 : 1; if (ctx->lock_failed) return 0; if (!ctx->locked) { if ((ret = mail_cache_lock(cache, TRUE)) <= 0) { ctx->lock_failed = TRUE; return ret; } ctx->locked = TRUE; } return 1; }