commit 698bf6f: [Minor] Sigh, another try to fix coroutines errors
Vsevolod Stakhov
vsevolod at highsecure.ru
Tue Mar 19 16:35:03 UTC 2019
Author: Vsevolod Stakhov
Date: 2019-03-19 16:30:31 +0000
URL: https://github.com/rspamd/rspamd/commit/698bf6f96d97eb8514c2b47519f120abe1f3df7f (HEAD -> master)
[Minor] Sigh, another try to fix coroutines errors
---
rules/regexp/misc.lua | 1 -
src/lua/lua_http.c | 21 +++++++++++++++++++--
2 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/rules/regexp/misc.lua b/rules/regexp/misc.lua
index f7ea49bc2..5f6e20a06 100644
--- a/rules/regexp/misc.lua
+++ b/rules/regexp/misc.lua
@@ -111,7 +111,6 @@ local id = rspamd_config:register_symbol{
callback = function(task)
local rspamd_re = require "rspamd_regexp"
local hash = require "rspamd_cryptobox_hash"
- local rspamd_logger = require "rspamd_logger"
if task:has_symbol('LEAKED_PASSWORD_SCAM') then
-- Perform BTC wallet check (quite expensive)
diff --git a/src/lua/lua_http.c b/src/lua/lua_http.c
index aba23e0dd..1a3f8a4a2 100644
--- a/src/lua/lua_http.c
+++ b/src/lua/lua_http.c
@@ -60,6 +60,7 @@ static const struct luaL_reg httplib_m[] = {
#define RSPAMD_LUA_HTTP_FLAG_NOVERIFY (1 << 1)
#define RSPAMD_LUA_HTTP_FLAG_RESOLVED (1 << 2)
#define RSPAMD_LUA_HTTP_FLAG_KEEP_ALIVE (1 << 3)
+#define RSPAMD_LUA_HTTP_FLAG_YIELDED (1 << 4)
struct lua_http_cbdata {
struct rspamd_http_connection *conn;
@@ -197,7 +198,14 @@ lua_http_error_handler (struct rspamd_http_connection *conn, GError *err)
{
struct lua_http_cbdata *cbd = (struct lua_http_cbdata *)conn->ud;
if (cbd->cbref == -1) {
- lua_http_resume_handler (conn, NULL, err->message);
+ if (cbd->flags & RSPAMD_LUA_HTTP_FLAG_YIELDED) {
+ cbd->flags &= ~RSPAMD_LUA_HTTP_FLAG_YIELDED;
+ lua_http_resume_handler (conn, NULL, err->message);
+ }
+ else {
+ /* TODO: kill me please */
+ msg_info ("lost HTTP error in coroutines mess: %s", err->message);
+ }
}
else {
lua_http_push_error (cbd, err->message);
@@ -219,7 +227,15 @@ lua_http_finish_handler (struct rspamd_http_connection *conn,
lua_State *L;
if (cbd->cbref == -1) {
- lua_http_resume_handler (conn, msg, NULL);
+ if (cbd->flags & RSPAMD_LUA_HTTP_FLAG_YIELDED) {
+ cbd->flags &= ~RSPAMD_LUA_HTTP_FLAG_YIELDED;
+ lua_http_resume_handler (conn, msg, NULL);
+ }
+ else {
+ /* TODO: kill me please */
+ msg_err ("lost HTTP data in coroutines mess");
+ }
+
REF_RELEASE (cbd);
return 0;
@@ -1036,6 +1052,7 @@ lua_http_request (lua_State *L)
if (cbd->cbref == -1) {
cbd->thread = lua_thread_pool_get_running_entry (cfg->lua_thread_pool);
+ cbd->flags |= RSPAMD_LUA_HTTP_FLAG_YIELDED;
return lua_thread_yield (cbd->thread, 0);
}
More information about the Commits
mailing list