From 8c2893be56c10af0a696282386b49fdb3c1e4a81 Mon Sep 17 00:00:00 2001 From: amelia squires Date: Wed, 15 Oct 2025 10:35:38 -0500 Subject: prevent double close --- src/thread.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/thread.c') diff --git a/src/thread.c b/src/thread.c index da4bcb5..bb18ad3 100644 --- a/src/thread.c +++ b/src/thread.c @@ -205,7 +205,7 @@ void* handle_thread(void* _args){ lua_assign_upvalues(L, x); lua_pushvalue(L, res_idx); lua_call(L, 1, 0); - + args->tid = 0; pthread_mutex_unlock(&*args->lock); return NULL; @@ -291,7 +291,7 @@ int _thread_close(lua_State* L){ lua_gettable(L, 1); struct thread_info* info = lua_touserdata(L, -1); - pthread_cancel(info->tid); + if(info->tid != 0) pthread_cancel(info->tid); info->tid = 0; return 0; @@ -306,7 +306,7 @@ int _thread_kill(lua_State* L){ lua_gettable(L, 1); struct thread_info* info = lua_touserdata(L, -1); - pthread_kill(info->tid, SIGUSR1); + if(info->tid != 0) pthread_kill(info->tid, SIGUSR1); info->tid = 0; return 0; -- cgit v1.2.3