int ret;
/* re-read header to make sure we don't lose any fields. */
- if (mail_cache_header_fields_read(cache) < 0) {
- (void)mail_cache_unlock(cache);
+ if (mail_cache_header_fields_read(cache) < 0)
return -1;
- }
if (cache->field_file_map[field_idx] != (uint32_t)-1) {
/* it was already added */
- if (mail_cache_unlock(cache) < 0)
- return -1;
return 0;
}
"lost unexpectedly", cache->filepath);
ret = -1;
}
-
- if (mail_cache_unlock(cache) < 0)
- ret = -1;
return ret;
}
unsigned int field_idx)
{
struct mail_cache *cache = ctx->cache;
+ int ret;
if (MAIL_INDEX_IS_IN_MEMORY(cache->index)) {
if (cache->file_fields_count <= field_idx) {
if (mail_cache_transaction_lock(ctx) <= 0)
return -1;
}
- return mail_cache_header_add_field_locked(cache, field_idx);
+ ret = mail_cache_header_add_field_locked(cache, field_idx);
+ if (mail_cache_unlock(cache) < 0)
+ ret = -1;
+ return ret;
}
static int