]> source.dussan.org Git - rspamd.git/commitdiff
[Project] Start optimization of userdata hashing
authorVsevolod Stakhov <vsevolod@rspamd.com>
Tue, 5 Mar 2024 13:39:47 +0000 (13:39 +0000)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Tue, 5 Mar 2024 13:39:47 +0000 (13:39 +0000)
18 files changed:
src/controller.c
src/libmime/message.c
src/libmime/scan_result.c
src/libserver/protocol.c
src/libserver/re_cache.c
src/libserver/task.c
src/libstat/backends/redis_backend.cxx
src/libstat/backends/sqlite3_backend.c
src/libstat/classifiers/lua_classifier.c
src/libstat/stat_process.c
src/lua/CMakeLists.txt
src/lua/lua_common.h
src/lua/lua_config.c
src/lua/lua_logger.c
src/lua/lua_task.c
src/plugins/fuzzy_check.c
src/plugins/regexp.c
src/rspamadm/lua_repl.c

index f05105e913af3758b9da2f4370593c77e1faf156..8df2dc248096df92c800e4a9aab42ba1313b67bb 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2023 Vsevolod Stakhov
+ * Copyright 2024 Vsevolod Stakhov
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -34,6 +34,7 @@
 #include "utlist.h"
 #include "libmime/lang_detection.h"
 #include "mempool_vars_internal.h"
+#include "lua/lua_classnames.h"
 #include <math.h>
 
 /* 60 seconds for worker's IO */
@@ -1555,7 +1556,7 @@ rspamd_controller_handle_lua_history(lua_State *L,
 
                                ptask = lua_newuserdata(L, sizeof(*ptask));
                                *ptask = task;
-                               rspamd_lua_setclass(L, "rspamd{task}", -1);
+                               rspamd_lua_setclass(L, rspamd_task_classname, -1);
                                pconn_ent = lua_newuserdata(L, sizeof(*pconn_ent));
                                *pconn_ent = conn_ent;
                                rspamd_lua_setclass(L, "rspamd{csession}", -1);
@@ -1916,7 +1917,7 @@ rspamd_controller_handle_lua(struct rspamd_http_connection_entry *conn_ent,
        }
 
        ptask = lua_newuserdata(L, sizeof(*ptask));
-       rspamd_lua_setclass(L, "rspamd{task}", -1);
+       rspamd_lua_setclass(L, rspamd_task_classname, -1);
        *ptask = task;
 
        pconn = lua_newuserdata(L, sizeof(*pconn));
@@ -3541,7 +3542,7 @@ rspamd_controller_handle_lua_plugin(struct rspamd_http_connection_entry *conn_en
 
        /* Task */
        ptask = lua_newuserdata(L, sizeof(*ptask));
-       rspamd_lua_setclass(L, "rspamd{task}", -1);
+       rspamd_lua_setclass(L, rspamd_task_classname, -1);
        *ptask = task;
 
        /* Connection */
index 3acc935e6c42b7635511d00fcb8e3dbfb01deb60..84870a8b0ab703ebe7e0f90940d0ae3ac7256f71 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2023 Vsevolod Stakhov
+ * Copyright 2024 Vsevolod Stakhov
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -994,7 +994,7 @@ rspamd_message_from_data(struct rspamd_task *task, const guchar *start,
                        rspamd_lua_setclass(L, "rspamd{mimepart}", -1);
                        *pmime = part;
                        ptask = lua_newuserdata(L, sizeof(struct rspamd_task *));
-                       rspamd_lua_setclass(L, "rspamd{task}", -1);
+                       rspamd_lua_setclass(L, rspamd_task_classname, -1);
                        *ptask = task;
 
                        if (lua_pcall(L, 2, 2, 0) != 0) {
@@ -1447,7 +1447,7 @@ void rspamd_message_process(struct rspamd_task *task)
                        rspamd_lua_setclass(L, "rspamd{mimepart}", -1);
                        *pmime = part;
                        ptask = lua_newuserdata(L, sizeof(struct rspamd_task *));
-                       rspamd_lua_setclass(L, "rspamd{task}", -1);
+                       rspamd_lua_setclass(L, rspamd_task_classname, -1);
                        *ptask = task;
 
                        if (lua_pcall(L, 2, 2, err_idx) != 0) {
@@ -1519,7 +1519,7 @@ void rspamd_message_process(struct rspamd_task *task)
                        rspamd_lua_setclass(L, "rspamd{mimepart}", -1);
                        *pmime = part;
                        ptask = lua_newuserdata(L, sizeof(struct rspamd_task *));
-                       rspamd_lua_setclass(L, "rspamd{task}", -1);
+                       rspamd_lua_setclass(L, rspamd_task_classname, -1);
                        *ptask = task;
 
                        if (lua_pcall(L, 2, 0, err_idx) != 0) {
index a6bc0cb8b8cbab85dccfd4a28f06819e820528c4..5c89b6560666dacab09181f690311dcfb65932ac 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2023 Vsevolod Stakhov
+ * Copyright 2024 Vsevolod Stakhov
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -566,7 +566,7 @@ rspamd_task_insert_result_full(struct rspamd_task *task,
 
                                if (!rspamd_lua_universal_pcall(L, mres->symbol_cbref,
                                                                                                G_STRLOC, 1, "uss", &err,
-                                                                                               "rspamd{task}", task, symbol, mres->name ? mres->name : "default")) {
+                                                                                               rspamd_task_classname, task, symbol, mres->name ? mres->name : "default")) {
                                        msg_warn_task("cannot call for symbol_cbref for result %s: %e",
                                                                  mres->name ? mres->name : "default", err);
                                        g_error_free(err);
index 8674557547454aa823d2197a4aac139dc4ccda5d..37a41c111a60a2dd8cf0f01341717bae0c460abb 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2023 Vsevolod Stakhov
+ * Copyright 2024 Vsevolod Stakhov
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,6 +27,7 @@
 #include "libserver/mempool_vars_internal.h"
 #include "contrib/fastutf8/fastutf8.h"
 #include "task.h"
+#include "lua/lua_classnames.h"
 #include <math.h>
 
 #ifdef SYS_ZSTD
@@ -1923,7 +1924,7 @@ void rspamd_protocol_write_log_pipe(struct rspamd_task *task)
                                if (lua_isfunction(L, -1)) {
                                        ptask = lua_newuserdata(L, sizeof(*ptask));
                                        *ptask = task;
-                                       rspamd_lua_setclass(L, "rspamd{task}", -1);
+                                       rspamd_lua_setclass(L, rspamd_task_classname, -1);
                                        /* stack:
                                         * -1: task
                                         * -2: func
index d51dba6477f8d6f89eff624da69faf05fc4a7267..15a52228bfefcf962d23c30042c76780d07ccd15 100644 (file)
@@ -25,6 +25,7 @@
 #include "lua/lua_common.h"
 #include "libstat/stat_api.h"
 #include "contrib/uthash/utlist.h"
+#include "lua/lua_classnames.h"
 
 #include "khash.h"
 
@@ -562,7 +563,7 @@ rspamd_re_cache_check_lua_condition(struct rspamd_task *task,
 
        if (!rspamd_lua_universal_pcall(L, lua_cbref,
                                                                        G_STRLOC, 1, "utii", &err,
-                                                                       "rspamd{task}", task,
+                                                                       rspamd_task_classname, task,
                                                                        text_pos, start, end)) {
                msg_warn_task("cannot call for re_cache_check_lua_condition for re %s: %e",
                                          rspamd_regexp_get_pattern(re), err);
@@ -908,7 +909,7 @@ rspamd_re_cache_process_selector(struct rspamd_task *task,
        lua_rawgeti(L, LUA_REGISTRYINDEX, ref);
        ptask = lua_newuserdata(L, sizeof(*ptask));
        *ptask = task;
-       rspamd_lua_setclass(L, "rspamd{task}", -1);
+       rspamd_lua_setclass(L, rspamd_task_classname, -1);
 
        if ((ret = lua_pcall(L, 1, 1, err_idx)) != 0) {
                msg_err_task("call to selector %s "
index 9763d1eb4785e51c50d3dc53bf9bcb96d0605a00..4518477fc19252ad8d284d2bdb297a2bd18a485f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2023 Vsevolod Stakhov
+ * Copyright 2024 Vsevolod Stakhov
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -29,6 +29,7 @@
 #include "libserver/cfg_file_private.h"
 #include "libmime/lang_detection.h"
 #include "libmime/scan_result_private.h"
+#include "lua/lua_classnames.h"
 
 #ifdef WITH_JEMALLOC
 #include <jemalloc/jemalloc.h>
@@ -1616,7 +1617,7 @@ void rspamd_task_write_log(struct rspamd_task *task)
                        L = task->cfg->lua_state;
                        lua_rawgeti(L, LUA_REGISTRYINDEX, GPOINTER_TO_INT(lf->data));
                        ptask = lua_newuserdata(L, sizeof(*ptask));
-                       rspamd_lua_setclass(L, "rspamd{task}", -1);
+                       rspamd_lua_setclass(L, rspamd_task_classname, -1);
                        *ptask = task;
 
                        if (lua_pcall(L, 1, 1, 0) != 0) {
index 14e82102970f96facb8d5a4c3696f830f27dea69..9cc0b123d488a5afbe9bdeb5fc163777d18e6d32 100644 (file)
@@ -218,7 +218,7 @@ gsize rspamd_redis_expand_object(const gchar *pattern,
                        lua_rawgeti(L, LUA_REGISTRYINDEX, ctx->cbref_user);
                        ptask = (struct rspamd_task **) lua_newuserdata(L, sizeof(struct rspamd_task *));
                        *ptask = task;
-                       rspamd_lua_setclass(L, "rspamd{task}", -1);
+                       rspamd_lua_setclass(L, rspamd_task_classname, -1);
 
                        if (lua_pcall(L, 1, 1, err_idx) != 0) {
                                msg_err_task("call to user extraction script failed: %s",
index 2fd34d83f6cfdc386c3a89a4347109d2fdf04d31..68b52128f9393b2e317abb4bc43882bd5f20d564 100644 (file)
@@ -1,11 +1,11 @@
-/*-
- * Copyright 2016 Vsevolod Stakhov
+/*
+ * Copyright 2024 Vsevolod Stakhov
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
- *   http://www.apache.org/licenses/LICENSE-2.0
+ *    http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -177,7 +177,7 @@ rspamd_sqlite3_get_user(struct rspamd_stat_sqlite3_db *db,
                lua_rawgeti(L, LUA_REGISTRYINDEX, db->cbref_user);
                ptask = lua_newuserdata(L, sizeof(struct rspamd_task *));
                *ptask = task;
-               rspamd_lua_setclass(L, "rspamd{task}", -1);
+               rspamd_lua_setclass(L, rspamd_task_classname, -1);
 
                if (lua_pcall(L, 1, 1, err_idx) != 0) {
                        msg_err_task("call to user extraction script failed: %s",
@@ -246,7 +246,7 @@ rspamd_sqlite3_get_language(struct rspamd_stat_sqlite3_db *db,
                lua_rawgeti(L, LUA_REGISTRYINDEX, db->cbref_language);
                ptask = lua_newuserdata(L, sizeof(struct rspamd_task *));
                *ptask = task;
-               rspamd_lua_setclass(L, "rspamd{task}", -1);
+               rspamd_lua_setclass(L, rspamd_task_classname, -1);
 
                if (lua_pcall(L, 1, 1, err_idx) != 0) {
                        msg_err_task("call to language extraction script failed: %s",
index b74330dcab1ffff59732a2fa84ec58838ea84bff..09b35c6a917bc07ea9ade86d3fe929f51dae681d 100644 (file)
@@ -1,11 +1,11 @@
-/*-
- * Copyright 2016 Vsevolod Stakhov
+/*
+ * Copyright 2024 Vsevolod Stakhov
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
- *   http://www.apache.org/licenses/LICENSE-2.0
+ *    http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -145,7 +145,7 @@ lua_classifier_classify(struct rspamd_classifier *cl,
        lua_rawgeti(L, LUA_REGISTRYINDEX, ctx->classify_ref);
        ptask = lua_newuserdata(L, sizeof(*ptask));
        *ptask = task;
-       rspamd_lua_setclass(L, "rspamd{task}", -1);
+       rspamd_lua_setclass(L, rspamd_task_classname, -1);
        pcfg = lua_newuserdata(L, sizeof(*pcfg));
        *pcfg = cl->cfg;
        rspamd_lua_setclass(L, "rspamd{classifier}", -1);
@@ -200,7 +200,7 @@ lua_classifier_learn_spam(struct rspamd_classifier *cl,
        lua_rawgeti(L, LUA_REGISTRYINDEX, ctx->learn_ref);
        ptask = lua_newuserdata(L, sizeof(*ptask));
        *ptask = task;
-       rspamd_lua_setclass(L, "rspamd{task}", -1);
+       rspamd_lua_setclass(L, rspamd_task_classname, -1);
        pcfg = lua_newuserdata(L, sizeof(*pcfg));
        *pcfg = cl->cfg;
        rspamd_lua_setclass(L, "rspamd{classifier}", -1);
index 8c1d8ff196e8884be4e607558343b4c8b8bf848e..c1d194694dc89c2a8848f0ac45082d679cfaa8f7 100644 (file)
@@ -1,11 +1,11 @@
-/*-
- * Copyright 2016 Vsevolod Stakhov
+/*
+ * Copyright 2024 Vsevolod Stakhov
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
- *   http://www.apache.org/licenses/LICENSE-2.0
+ *    http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -21,6 +21,7 @@
 #include "libmime/images.h"
 #include "libserver/html/html.h"
 #include "lua/lua_common.h"
+#include "lua/lua_classnames.h"
 #include "libserver/mempool_vars_internal.h"
 #include "utlist.h"
 #include <math.h>
@@ -54,7 +55,7 @@ rspamd_stat_tokenize_parts_metadata(struct rspamd_stat_ctx *st_ctx,
 
                ptask = lua_newuserdata(L, sizeof(*ptask));
                *ptask = task;
-               rspamd_lua_setclass(L, "rspamd{task}", -1);
+               rspamd_lua_setclass(L, rspamd_task_classname, -1);
 
                if ((ret = lua_pcall(L, 1, 1, err_idx)) != 0) {
                        msg_err_task("call to stat_tokens lua "
@@ -210,7 +211,7 @@ rspamd_stat_classifier_is_skipped(struct rspamd_task *task,
                /* Push task and two booleans: is_spam and is_unlearn */
                struct rspamd_task **ptask = lua_newuserdata(L, sizeof(*ptask));
                *ptask = task;
-               rspamd_lua_setclass(L, "rspamd{task}", -1);
+               rspamd_lua_setclass(L, rspamd_task_classname, -1);
 
                if (is_learn) {
                        lua_pushboolean(L, is_spam);
@@ -1063,7 +1064,7 @@ rspamd_stat_check_autolearn(struct rspamd_task *task)
 
                                                ptask = lua_newuserdata(L, sizeof(struct rspamd_task *));
                                                *ptask = task;
-                                               rspamd_lua_setclass(L, "rspamd{task}", -1);
+                                               rspamd_lua_setclass(L, rspamd_task_classname, -1);
 
                                                if (lua_pcall(L, 1, 1, err_idx) != 0) {
                                                        msg_err_task("call to autolearn script failed: "
@@ -1118,7 +1119,7 @@ rspamd_stat_check_autolearn(struct rspamd_task *task)
 
                                        ptask = lua_newuserdata(L, sizeof(struct rspamd_task *));
                                        *ptask = task;
-                                       rspamd_lua_setclass(L, "rspamd{task}", -1);
+                                       rspamd_lua_setclass(L, rspamd_task_classname, -1);
                                        /* Push the whole object as well */
                                        ucl_object_push_lua(L, obj, true);
 
index a504f99f8a0e35cc54a7ee493ba7ccda5c45c007..46de053bae2e2e401fd3e87ce24057d9641a99a5 100644 (file)
@@ -34,6 +34,7 @@ SET(LUASRC                      ${CMAKE_CURRENT_SOURCE_DIR}/lua_common.c
                                          ${CMAKE_CURRENT_SOURCE_DIR}/lua_spf.c
                                          ${CMAKE_CURRENT_SOURCE_DIR}/lua_tensor.c
                                          ${CMAKE_CURRENT_SOURCE_DIR}/lua_parsers.c
-                                         ${CMAKE_CURRENT_SOURCE_DIR}/lua_compress.c)
+                                         ${CMAKE_CURRENT_SOURCE_DIR}/lua_compress.c
+                                         ${CMAKE_CURRENT_SOURCE_DIR}/lua_classnames.c)
 
 SET(RSPAMD_LUA ${LUASRC} PARENT_SCOPE)
\ No newline at end of file
index cc2b94390cf3968a4c4724eedf5cd61ca46e50d8..b46c0bfc9cfae3835f15472344d9b0a5fbf635f1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2023 Vsevolod Stakhov
+ * Copyright 2024 Vsevolod Stakhov
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,6 +19,7 @@
 
 #include "config.h"
 
+
 /* Lua headers do not have __cplusplus guards... */
 #ifdef __cplusplus
 extern "C" {
@@ -40,6 +41,7 @@ extern "C" {
 #include "rspamd.h"
 #include "ucl.h"
 #include "lua_ucl.h"
+#include "lua_classnames.h"
 
 #ifdef __cplusplus
 extern "C" {
index a044827a7ef5e57e161e059c4e038ba5cc8a1074..5e3eacd29742a23c940fff1c538bee41e070e0c3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2023 Vsevolod Stakhov
+ * Copyright 2024 Vsevolod Stakhov
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -1242,7 +1242,7 @@ lua_metric_symbol_callback(struct rspamd_task *task,
        }
 
        ptask = lua_newuserdata(L, sizeof(struct rspamd_task *));
-       rspamd_lua_setclass(L, "rspamd{task}", -1);
+       rspamd_lua_setclass(L, rspamd_task_classname, -1);
        *ptask = task;
 
        if ((ret = lua_pcall(L, 1, LUA_MULTRET, err_idx)) != 0) {
@@ -1382,7 +1382,7 @@ lua_metric_symbol_callback_coro(struct rspamd_task *task,
        }
 
        ptask = lua_newuserdata(thread, sizeof(struct rspamd_task *));
-       rspamd_lua_setclass(thread, "rspamd{task}", -1);
+       rspamd_lua_setclass(thread, rspamd_task_classname, -1);
        *ptask = task;
 
        thread_entry->finish_callback = lua_metric_symbol_callback_return;
@@ -4773,7 +4773,7 @@ void lua_call_finish_script(struct rspamd_config_cfg_lua_script *sc,
        lua_rawgeti(L, LUA_REGISTRYINDEX, sc->cbref);
 
        ptask = lua_newuserdata(L, sizeof(struct rspamd_task *));
-       rspamd_lua_setclass(L, "rspamd{task}", -1);
+       rspamd_lua_setclass(L, rspamd_task_classname, -1);
        *ptask = task;
 
        lua_thread_call(thread, 1);
index f4f8f3dbfed899cef290a1acc0cfb3a56cceded3..b9969b86b9b38e333985cbf20d6d14a869b6c393 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2023 Vsevolod Stakhov
+ * Copyright 2024 Vsevolod Stakhov
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -653,7 +653,7 @@ lua_logger_get_id(lua_State *L, gint pos, GError **err)
 
                clsname = lua_tostring(L, -1);
 
-               if (strcmp(clsname, "rspamd{task}") == 0) {
+               if (strcmp(clsname, rspamd_task_classname) == 0) {
                        struct rspamd_task *task = lua_check_task(L, pos);
 
                        if (task) {
index dd2ca108b633d914e6a7ee04eb9252780758d629..79cf9c55ef20f2b6a75a2096f976c690c29d4ae0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2023 Vsevolod Stakhov
+ * Copyright 2024 Vsevolod Stakhov
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -1382,7 +1382,7 @@ static const struct luaL_reg archivelib_m[] = {
 struct rspamd_task *
 lua_check_task(lua_State *L, gint pos)
 {
-       void *ud = rspamd_lua_check_udata(L, pos, "rspamd{task}");
+       void *ud = rspamd_lua_check_udata(L, pos, rspamd_task_classname);
        luaL_argcheck(L, ud != NULL, pos, "'task' expected");
        return ud ? *((struct rspamd_task **) ud) : NULL;
 }
@@ -1390,7 +1390,7 @@ lua_check_task(lua_State *L, gint pos)
 struct rspamd_task *
 lua_check_task_maybe(lua_State *L, gint pos)
 {
-       void *ud = rspamd_lua_check_udata_maybe(L, pos, "rspamd{task}");
+       void *ud = rspamd_lua_check_udata_maybe(L, pos, rspamd_task_classname);
 
        return ud ? *((struct rspamd_task **) ud) : NULL;
 }
@@ -1781,7 +1781,7 @@ lua_task_load_from_file(lua_State *L)
        if (res) {
                ptask = lua_newuserdata(L, sizeof(*ptask));
                *ptask = task;
-               rspamd_lua_setclass(L, "rspamd{task}", -1);
+               rspamd_lua_setclass(L, rspamd_task_classname, -1);
        }
        else {
                if (err) {
@@ -1832,7 +1832,7 @@ lua_task_load_from_string(lua_State *L)
 
        ptask = lua_newuserdata(L, sizeof(*ptask));
        *ptask = task;
-       rspamd_lua_setclass(L, "rspamd{task}", -1);
+       rspamd_lua_setclass(L, rspamd_task_classname, -1);
 
        return 2;
 }
@@ -1868,7 +1868,7 @@ lua_task_create(lua_State *L)
 
        ptask = lua_newuserdata(L, sizeof(*ptask));
        *ptask = task;
-       rspamd_lua_setclass(L, "rspamd{task}", -1);
+       rspamd_lua_setclass(L, rspamd_task_classname, -1);
 
        return 1;
 }
@@ -7271,7 +7271,7 @@ luaopen_archive(lua_State *L)
 
 void luaopen_task(lua_State *L)
 {
-       rspamd_lua_new_class(L, "rspamd{task}", tasklib_m);
+       rspamd_lua_new_class(L, rspamd_task_classname, tasklib_m);
        lua_pop(L, 1);
 
        rspamd_lua_add_preload(L, "rspamd_task", lua_load_task);
@@ -7290,6 +7290,6 @@ void rspamd_lua_task_push(lua_State *L, struct rspamd_task *task)
        struct rspamd_task **ptask;
 
        ptask = lua_newuserdata(L, sizeof(gpointer));
-       rspamd_lua_setclass(L, "rspamd{task}", -1);
+       rspamd_lua_setclass(L, rspamd_task_classname, -1);
        *ptask = task;
 }
index 85db83d08816e310ddcf7f342733f768081d4fd9..581c1c12d15183fcaa597e1309845b8321519b22 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2023 Vsevolod Stakhov
+ * Copyright 2024 Vsevolod Stakhov
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -1566,7 +1566,7 @@ fuzzy_rule_check_mimepart(struct rspamd_task *task,
 
                ptask = lua_newuserdata(L, sizeof(*ptask));
                *ptask = task;
-               rspamd_lua_setclass(L, "rspamd{task}", -1);
+               rspamd_lua_setclass(L, rspamd_task_classname, -1);
 
                ppart = lua_newuserdata(L, sizeof(*ppart));
                *ppart = part;
@@ -3510,7 +3510,7 @@ fuzzy_process_handler(struct rspamd_http_connection_entry *conn_ent,
                        lua_rawgeti(L, LUA_REGISTRYINDEX, rule->learn_condition_cb);
                        ptask = lua_newuserdata(L, sizeof(struct rspamd_task *));
                        *ptask = task;
-                       rspamd_lua_setclass(L, "rspamd{task}", -1);
+                       rspamd_lua_setclass(L, rspamd_task_classname, -1);
 
                        if (lua_pcall(L, 1, LUA_MULTRET, err_idx) != 0) {
                                msg_err_task("call to fuzzy learn condition failed: %s",
index 59a84c5076870c8c12c9cec7d38d71dcb454ee9a..83d2fc96388a28814d15b228962970168201496e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2023 Vsevolod Stakhov
+ * Copyright 2024 Vsevolod Stakhov
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -475,7 +475,7 @@ rspamd_lua_call_expression_func(struct ucl_lua_funcdata *lua_data,
        lua_rawgeti(L, LUA_REGISTRYINDEX, lua_data->idx);
        /* Now we got function in top of stack */
        ptask = lua_newuserdata(L, sizeof(struct rspamd_task *));
-       rspamd_lua_setclass(L, "rspamd{task}", -1);
+       rspamd_lua_setclass(L, rspamd_task_classname, -1);
        *ptask = task;
 
        /* Now push all arguments */
index 432c4de76e7e816ad1b77797e2d2dab2472c5987..d3f32c9db7eeee4beb6d2a7b851db18a31f8d7cb 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2023 Vsevolod Stakhov
+ * Copyright 2024 Vsevolod Stakhov
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -448,7 +448,7 @@ rspamadm_lua_message_handler(lua_State *L, gint argc, gchar **argv)
                        lua_pushvalue(L, func_idx);
                        ptask = lua_newuserdata(L, sizeof(*ptask));
                        *ptask = task;
-                       rspamd_lua_setclass(L, "rspamd{task}", -1);
+                       rspamd_lua_setclass(L, rspamd_task_classname, -1);
 
 
                        if (lua_repl_thread_call(thread, 1, argv[i], lua_thread_str_error_cb) == 0) {