diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2023-10-13 21:23:42 +0200 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2023-10-13 21:23:42 +0200 |
| commit | 9209e57bd965964b3853d8affecea571e6021b58 (patch) | |
| tree | 5ce7c260cd0b742675684266906de37e3972b8ae /src/box64context.c | |
| parent | 1e1ad7694b59dba4af4e70c978fdb1b2c7d17b5b (diff) | |
| download | box64-9209e57bd965964b3853d8affecea571e6021b58.tar.gz box64-9209e57bd965964b3853d8affecea571e6021b58.zip | |
Various changes on pthread cancel and tls destructor, should be easier to maintain
Diffstat (limited to 'src/box64context.c')
| -rw-r--r-- | src/box64context.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/box64context.c b/src/box64context.c index 234657ca..e38d0d33 100644 --- a/src/box64context.c +++ b/src/box64context.c @@ -68,6 +68,8 @@ void free_tlsdatasize(void* p) tlsdatasize_t *data = (tlsdatasize_t*)p; box_free(data->ptr); box_free(p); + if(my_context) + pthread_setspecific(my_context->tlskey, NULL); } void x64Syscall(x64emu_t *emu); @@ -236,7 +238,7 @@ box64context_t *NewBox64Context(int argc) init_mutexes(context); pthread_atfork(NULL, NULL, atfork_child_box64context); - pthread_key_create(&context->tlskey, free_tlsdatasize); + pthread_key_create(&context->tlskey, NULL/*free_tlsdatasize*/); for (int i=0; i<8; ++i) context->canary[i] = 1 + getrand(255); @@ -278,6 +280,7 @@ void FreeBox64Context(box64context_t** context) box64context_t* ctx = *context; // local copy to do the cleanning + //clean_current_emuthread(); // cleaning main thread seems a bad idea if(ctx->local_maplib) FreeLibrarian(&ctx->local_maplib, NULL); if(ctx->maplib) @@ -342,7 +345,6 @@ void FreeBox64Context(box64context_t** context) void* ptr; if ((ptr = pthread_getspecific(ctx->tlskey)) != NULL) { free_tlsdatasize(ptr); - pthread_setspecific(ctx->tlskey, NULL); } pthread_key_delete(ctx->tlskey); |