Skip to content

Commit

Permalink
lib-dict: Added dict_transaction_no_slowness_warning()
Browse files Browse the repository at this point in the history
  • Loading branch information
sirainen authored and GitLab committed Aug 17, 2016
1 parent 56558eb commit aef407f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib-dict/dict-client.c
Expand Up @@ -1045,7 +1045,7 @@ client_dict_transaction_commit_callback(struct client_dict_cmd *cmd,
/* include timing info always in error messages */
result.error = t_strdup_printf("%s (reply took %u.%03u secs)",
result.error, diff/1000, diff%1000);
} else if (!cmd->background &&
} else if (!cmd->background && !cmd->trans->ctx.no_slowness_warning &&
diff >= DICT_CLIENT_REQUEST_WARN_TIMEOUT_MSECS) {
i_warning("read(%s): dict commit took %u.%03u seconds: "
"%s (%u commands, first: %s)",
Expand Down
1 change: 1 addition & 0 deletions src/lib-dict/dict-private.h
Expand Up @@ -61,6 +61,7 @@ struct dict_transaction_context {
struct dict *dict;

bool changed:1;
bool no_slowness_warning:1;
};

void dict_transaction_commit_async_noop_callback(
Expand Down
5 changes: 5 additions & 0 deletions src/lib-dict/dict.c
Expand Up @@ -202,6 +202,11 @@ struct dict_transaction_context *dict_transaction_begin(struct dict *dict)
return dict->v.transaction_init(dict);
}

void dict_transaction_no_slowness_warning(struct dict_transaction_context *ctx)
{
ctx->no_slowness_warning = TRUE;
}

struct dict_commit_sync_result {
int ret;
char *error;
Expand Down
5 changes: 5 additions & 0 deletions src/lib-dict/dict.h
Expand Up @@ -120,6 +120,11 @@ int dict_iterate_deinit(struct dict_iterate_context **ctx, const char **error_r)

/* Start a new dictionary transaction. */
struct dict_transaction_context *dict_transaction_begin(struct dict *dict);
/* Don't log a warning if the transaction commit took a long time.
This is needed if there are no guarantees that an asynchronous commit will
finish up anytime soon. Mainly useful for transactions which aren't
especially important whether they finish or not. */
void dict_transaction_no_slowness_warning(struct dict_transaction_context *ctx);
/* Commit the transaction. Returns 1 if ok, 0 if dict_atomic_inc() was used
on a nonexistent key, -1 if failed. */
int dict_transaction_commit(struct dict_transaction_context **ctx,
Expand Down

0 comments on commit aef407f

Please sign in to comment.