aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoramelia squires <[email protected]>2025-10-15 10:35:38 -0500
committeramelia squires <[email protected]>2025-10-15 10:35:38 -0500
commit8c2893be56c10af0a696282386b49fdb3c1e4a81 (patch)
tree043c7a846899f8853d50b6af043021110716610c /src
parentaf09c42e8067dfc832f7e1dce92860e1022c75fa (diff)
prevent double close
Diffstat (limited to 'src')
-rw-r--r--src/thread.c6
1 files changed, 3 insertions, 3 deletions
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;