Mercurial > dovecot > core-2.2
view src/lib-dict/dict-transaction-memory.c @ 22325:e01bc3015b2f
lib-index: Check .log.2 rotation only when syncing
Instead of also whenever appending transactions to .log file. This
shouldn't change the behavior much, and it's needed for the following
change to work correctly.
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Tue, 11 Jul 2017 15:33:56 +0300 |
parents | 2e2563132d5f |
children | cb108f786fb4 |
line wrap: on
line source
/* Copyright (c) 2005-2017 Dovecot authors, see the included COPYING file */ #include "lib.h" #include "array.h" #include "dict-transaction-memory.h" void dict_transaction_memory_init(struct dict_transaction_memory_context *ctx, struct dict *dict, pool_t pool) { ctx->ctx.dict = dict; ctx->pool = pool; p_array_init(&ctx->changes, pool, 32); } void dict_transaction_memory_rollback(struct dict_transaction_context *_ctx) { struct dict_transaction_memory_context *ctx = (struct dict_transaction_memory_context *)_ctx; pool_unref(&ctx->pool); } void dict_transaction_memory_set(struct dict_transaction_context *_ctx, const char *key, const char *value) { struct dict_transaction_memory_context *ctx = (struct dict_transaction_memory_context *)_ctx; struct dict_transaction_memory_change *change; change = array_append_space(&ctx->changes); change->type = DICT_CHANGE_TYPE_SET; change->key = p_strdup(ctx->pool, key); change->value.str = p_strdup(ctx->pool, value); } void dict_transaction_memory_unset(struct dict_transaction_context *_ctx, const char *key) { struct dict_transaction_memory_context *ctx = (struct dict_transaction_memory_context *)_ctx; struct dict_transaction_memory_change *change; change = array_append_space(&ctx->changes); change->type = DICT_CHANGE_TYPE_UNSET; change->key = p_strdup(ctx->pool, key); } void dict_transaction_memory_append(struct dict_transaction_context *_ctx, const char *key, const char *value) { struct dict_transaction_memory_context *ctx = (struct dict_transaction_memory_context *)_ctx; struct dict_transaction_memory_change *change; change = array_append_space(&ctx->changes); change->type = DICT_CHANGE_TYPE_APPEND; change->key = p_strdup(ctx->pool, key); change->value.str = p_strdup(ctx->pool, value); } void dict_transaction_memory_atomic_inc(struct dict_transaction_context *_ctx, const char *key, long long diff) { struct dict_transaction_memory_context *ctx = (struct dict_transaction_memory_context *)_ctx; struct dict_transaction_memory_change *change; change = array_append_space(&ctx->changes); change->type = DICT_CHANGE_TYPE_INC; change->key = p_strdup(ctx->pool, key); change->value.diff = diff; }