diff options
author | Mikhail Galanin <mgalanin@mimecast.com> | 2018-08-30 16:50:55 +0100 |
---|---|---|
committer | Mikhail Galanin <mgalanin@mimecast.com> | 2018-08-30 16:50:55 +0100 |
commit | a78803aeb558c0ebb9ada2a0f71f960ac31f373d (patch) | |
tree | 340ec4be7267235b779025f6d4db745ec714483b /src/lua/lua_thread_pool.c | |
parent | 112ed7966d7fcaf7f0a16a79b0af51e7d339e744 (diff) | |
download | rspamd-a78803aeb558c0ebb9ada2a0f71f960ac31f373d.tar.gz rspamd-a78803aeb558c0ebb9ada2a0f71f960ac31f373d.zip |
[Minor] Added coroutines support for TCP library
Diffstat (limited to 'src/lua/lua_thread_pool.c')
-rw-r--r-- | src/lua/lua_thread_pool.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/lua/lua_thread_pool.c b/src/lua/lua_thread_pool.c index 3fc14534d..df3ed775e 100644 --- a/src/lua/lua_thread_pool.c +++ b/src/lua/lua_thread_pool.c @@ -158,6 +158,20 @@ lua_thread_pool_set_running_entry (struct lua_thread_pool *pool, struct thread_e pool->running_entry = thread_entry; } +static void +lua_thread_pool_set_running_entry_for_thread (struct thread_entry *thread_entry) +{ + struct lua_thread_pool *pool; + + if (thread_entry->task) { + pool = thread_entry->task->cfg->lua_thread_pool; + } + else { + pool = thread_entry->cfg->lua_thread_pool; + } + + lua_thread_pool_set_running_entry (pool, thread_entry); +} void lua_thread_pool_prepare_callback (struct lua_thread_pool *pool, struct lua_callback_state *cbs) @@ -206,6 +220,8 @@ lua_thread_resume (struct thread_entry *thread_entry, gint narg) */ g_assert (lua_status (thread_entry->lua_state) == LUA_YIELD); + lua_thread_pool_set_running_entry_for_thread(thread_entry); + lua_resume_thread_internal (thread_entry, narg); } @@ -263,5 +279,7 @@ lua_resume_thread_internal (struct thread_entry *thread_entry, gint narg) gint lua_thread_yield (struct thread_entry *thread_entry, gint nresults) { + g_assert (lua_status (thread_entry->lua_state) == 0); + return lua_yield (thread_entry->lua_state, nresults); } |