]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-dict-backend: Replace i_<log>() with e_<log>()
authorMarco Bettini <marco.bettini@open-xchange.com>
Tue, 4 Oct 2022 15:37:58 +0000 (15:37 +0000)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Wed, 26 Oct 2022 16:35:08 +0000 (16:35 +0000)
src/lib-dict-backend/dict-ldap.c
src/lib-dict-backend/dict-sql.c

index 2142184cc92b511d63f4e3b6ba66285b28b684fa..d9f35b0f1322b142f63aba75d5b917d02ea81031 100644 (file)
@@ -23,6 +23,7 @@ struct ldap_dict;
 
 struct dict_ldap_op {
        struct ldap_dict *dict;
+       struct event *event;
        const struct dict_ldap_map *map;
        pool_t pool;
        unsigned long txid;
@@ -327,23 +328,25 @@ ldap_dict_lookup_callback(struct ldap_result *result, struct dict_ldap_op *op)
                iter = ldap_search_iterator_init(result);
                entry = ldap_search_iterator_next(iter);
                if (entry != NULL) {
-                       if (op->dict->set->debug > 0)
-                               i_debug("ldap_dict_lookup_callback got dn %s", ldap_entry_dn(entry));
+                       e_debug(op->event, "ldap_dict_lookup_callback got dn %s",
+                               ldap_entry_dn(entry));
                        /* try extract value */
                        const char *const *values = ldap_entry_get_attribute(entry, op->map->value_attribute);
                        if (values != NULL) {
                                const char **new_values;
 
-                               if (op->dict->set->debug > 0)
-                                       i_debug("ldap_dict_lookup_callback got attribute %s", op->map->value_attribute);
+                               e_debug(op->event,
+                                       "ldap_dict_lookup_callback got attribute %s",
+                                       op->map->value_attribute);
                                op->res.ret = 1;
                                new_values = p_new(op->pool, const char *, 2);
                                new_values[0] = p_strdup(op->pool, values[0]);
                                op->res.values = new_values;
                                op->res.value = op->res.values[0];
                        } else {
-                               if (op->dict->set->debug > 0)
-                                       i_debug("ldap_dict_lookup_callback dit not get attribute %s", op->map->value_attribute);
+                               e_debug(op->event,
+                                       "ldap_dict_lookup_callback dit not get attribute %s",
+                                       op->map->value_attribute);
                                op->res.value = NULL;
                        }
                }
@@ -356,6 +359,8 @@ ldap_dict_lookup_callback(struct ldap_result *result, struct dict_ldap_op *op)
                io_loop_set_current(op->dict->dict.ioloop);
                io_loop_stop(op->dict->dict.ioloop);
        }
+
+       event_unref(&op->event);
        pool_unref(&pool);
 }
 
@@ -442,6 +447,9 @@ void ldap_dict_lookup_async(struct dict *dict,
        op->callback_ctx = context;
        op->txid = ctx->last_txid++;
 
+       op->event = event_create(op->dict->dict.event);
+       event_set_forced_debug(op->event, op->dict->set->debug > 0);
+
        /* key needs to be transformed into something else */
        ARRAY_TYPE(const_string) values;
        const char *attributes[2] = {0, 0};
@@ -458,6 +466,7 @@ void ldap_dict_lookup_async(struct dict *dict,
                if (!ldap_dict_build_query(set, map, &values, strncmp(key, DICT_PATH_PRIVATE, strlen(DICT_PATH_PRIVATE))==0, query, &error)) {
                        op->res.error = error;
                        callback(&op->res, context);
+                       event_unref(&op->event);
                        pool_unref(&oppool);
                        return;
                }
@@ -469,6 +478,7 @@ void ldap_dict_lookup_async(struct dict *dict,
        } else {
                op->res.error = "no such key";
                callback(&op->res, context);
+               event_unref(&op->event);
                pool_unref(&oppool);
        }
 }
index d030a9a543f6875ff4bea4e19907973835d2e9c4..f520a76d433eda4d8899a3b76aa40876805e7bd1 100644 (file)
@@ -1005,7 +1005,7 @@ sql_dict_transaction_commit_callback(const struct sql_commit_result *sql_result,
        if (ctx->async_callback != NULL)
                ctx->async_callback(&result, ctx->async_context);
        else if (result.ret < 0)
-               i_error("%s", result.error);
+               e_error(ctx->ctx.event, "%s", result.error);
        sql_dict_transaction_free(ctx);
 }