diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-03-19 16:30:31 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-03-19 16:30:31 +0000 |
commit | 698bf6f96d97eb8514c2b47519f120abe1f3df7f (patch) | |
tree | 8a004cb517b1da378ce19f054c4ea510ad1bb18a /src/lua/lua_http.c | |
parent | c427048cec9cbdbd0da8457dfbd6ffbd6bdab02b (diff) | |
download | rspamd-698bf6f96d97eb8514c2b47519f120abe1f3df7f.tar.gz rspamd-698bf6f96d97eb8514c2b47519f120abe1f3df7f.zip |
[Minor] Sigh, another try to fix coroutines errors
Diffstat (limited to 'src/lua/lua_http.c')
-rw-r--r-- | src/lua/lua_http.c | 21 |
1 files changed, 19 insertions, 2 deletions
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); } |