diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2021-07-05 11:35:27 +0200 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2021-07-05 11:35:27 +0200 |
| commit | c3cd14f3c529d75de5130facc3542f4a0f56d7f9 (patch) | |
| tree | d936a68ddb784f69511274c139848feba67bf9bc /src/tools | |
| parent | 2010f8dcce4349e1420755a94f9af2211e9574c8 (diff) | |
| download | box64-c3cd14f3c529d75de5130facc3542f4a0f56d7f9.tar.gz box64-c3cd14f3c529d75de5130facc3542f4a0f56d7f9.zip | |
Removed mutex per bridge and use a global one (remove chance of freeze on fork)
Diffstat (limited to 'src/tools')
| -rwxr-xr-x | src/tools/bridge.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/tools/bridge.c b/src/tools/bridge.c index e05bb1a3..8dc67ce1 100755 --- a/src/tools/bridge.c +++ b/src/tools/bridge.c @@ -30,7 +30,6 @@ typedef struct brick_s { typedef struct bridge_s { brick_t *head; brick_t *last; // to speed up - pthread_mutex_t mutex; kh_bridgemap_t *bridgemap; } bridge_t; @@ -48,7 +47,6 @@ bridge_t *NewBridge() bridge_t *b = (bridge_t*)calloc(1, sizeof(bridge_t)); b->head = NewBrick(); b->last = b->head; - pthread_mutex_init(&b->mutex, NULL); b->bridgemap = kh_init(bridgemap); return b; @@ -69,7 +67,6 @@ void FreeBridge(bridge_t** bridge) b = n; } kh_destroy(bridgemap, (*bridge)->bridgemap); - pthread_mutex_destroy(&(*bridge)->mutex); free(*bridge); *bridge = NULL; } @@ -86,7 +83,7 @@ uintptr_t AddBridge(bridge_t* bridge, wrapper_t w, void* fnc, int N, const char* int prot = 0; do { #endif - pthread_mutex_lock(&bridge->mutex); + pthread_mutex_lock(&my_context->mutex_bridge); b = bridge->last; if(b->sz == NBRICK) { b->next = NewBrick(); @@ -95,7 +92,7 @@ uintptr_t AddBridge(bridge_t* bridge, wrapper_t w, void* fnc, int N, const char* } sz = b->sz; #ifdef DYNAREC - pthread_mutex_unlock(&bridge->mutex); + pthread_mutex_unlock(&my_context->mutex_bridge); if(box64_dynarec) { prot=(getProtection((uintptr_t)b->b)&PROT_DYNAREC)?1:0; if(prot) @@ -104,7 +101,7 @@ uintptr_t AddBridge(bridge_t* bridge, wrapper_t w, void* fnc, int N, const char* addDBFromAddressRange((uintptr_t)&b->b[b->sz].CC, sizeof(onebridge_t)); } } while(sz!=b->sz); // this while loop if someone took the slot when the bridge mutex was unlocked doing memory protection managment - pthread_mutex_lock(&bridge->mutex); + pthread_mutex_lock(&my_context->mutex_bridge); #endif b->sz++; b->b[sz].CC = 0xCC; @@ -117,7 +114,7 @@ uintptr_t AddBridge(bridge_t* bridge, wrapper_t w, void* fnc, int N, const char* int ret; khint_t k = kh_put(bridgemap, bridge->bridgemap, (uintptr_t)fnc, &ret); kh_value(bridge->bridgemap, k) = (uintptr_t)&b->b[sz].CC; - pthread_mutex_unlock(&bridge->mutex); + pthread_mutex_unlock(&my_context->mutex_bridge); #ifdef DYNAREC if(box64_dynarec) protectDB((uintptr_t)b->b, NBRICK*sizeof(onebridge_t)); |