]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Allow forced termination of the suspended threads
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 5 May 2021 10:37:43 +0000 (11:37 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 5 May 2021 10:37:43 +0000 (11:37 +0100)
src/lua/lua_redis.c
src/lua/lua_thread_pool.c
src/lua/lua_thread_pool.h

index b624fc43bf55b045562e451d9ef890f6682ebc4e..057a21c958897b641de74182a6d258206ca7fe49 100644 (file)
@@ -685,8 +685,8 @@ lua_redis_callback_sync (redisAsyncContext *ac, gpointer r, gpointer priv)
                        }
                        else {
                                /* We cannot resume the thread as the associated task has gone */
-                               lua_thread_pool_terminate_entry (ud->cfg->lua_thread_pool,
-                                               ctx->thread);
+                               lua_thread_pool_terminate_entry_full (ud->cfg->lua_thread_pool,
+                                               ctx->thread, G_STRLOC, true);
                                ctx->thread = NULL;
                        }
                }
index 01c55b4a9dcb9316064c02968a5dc9457498e81b..50c53698c7a3cecd63ce652a29d074115a9faf66 100644 (file)
@@ -159,12 +159,17 @@ lua_thread_pool_return_full (struct lua_thread_pool *pool,
 
 void
 lua_thread_pool_terminate_entry_full (struct lua_thread_pool *pool,
-               struct thread_entry *thread_entry, const gchar *loc)
+                                                                         struct thread_entry *thread_entry, const gchar *loc,
+                                                                         bool enforce)
 {
        struct thread_entry *ent = NULL;
 
-       /* we should only terminate failed threads */
-       g_assert (lua_status (thread_entry->lua_state) != 0 && lua_status (thread_entry->lua_state) != LUA_YIELD);
+
+       if (!enforce) {
+               /* we should only terminate failed threads */
+               g_assert (lua_status(thread_entry->lua_state) != 0 &&
+                       lua_status(thread_entry->lua_state) != LUA_YIELD);
+       }
 
        if (pool->running_entry == thread_entry) {
                pool->running_entry = NULL;
@@ -327,7 +332,7 @@ lua_resume_thread_internal_full (struct thread_entry *thread_entry,
                         * Maybe there is a way to recover here.
                         * For now, just remove faulty thread
                         */
-                       lua_thread_pool_terminate_entry_full (pool, thread_entry, loc);
+                       lua_thread_pool_terminate_entry_full (pool, thread_entry, loc, false);
                }
        }
 }
index 66c8b991ce4bceccbe89e8a1533fb760dfab1d09..2845d2f6747abfb2224463ef5e9e89988900ccd2 100644 (file)
@@ -192,9 +192,9 @@ lua_thread_resume_full (struct thread_entry *thread_entry,
 void
 lua_thread_pool_terminate_entry_full (struct lua_thread_pool *pool,
                                                                 struct thread_entry *thread_entry,
-                                                                const gchar *loc);
+                                                                const gchar *loc, bool enforce);
 #define lua_thread_pool_terminate_entry(pool, thread_entry) \
-    lua_thread_pool_terminate_entry_full (pool, thread_entry, G_STRLOC)
+    lua_thread_pool_terminate_entry_full (pool, thread_entry, G_STRLOC, false)
 
 #ifdef  __cplusplus
 }