mirror of
https://git.checksum.fail/alec/slon.git
synced 2025-12-08 12:09:55 +02:00
System/FFI/LibC: Round-robin mem_task selection for malloc
This fixes an issue where multiple HTTP requests would arrive simultaneously, and the subsequent calls to @rsa_import would end up clobbering the shared mem_task's CHeapCtrl, leading to #GP. Eventually, we may want to simplify this to only init the CHeapCtrl, rather than creating the entire CTask, but for now it seems ok.
This commit is contained in:
@@ -118,11 +118,18 @@ U0 ntohs()
|
||||
POP_SYSV_REGS
|
||||
}
|
||||
|
||||
U64 @malloc(I64 size)
|
||||
{
|
||||
U64 res = MAlloc(size, malloc_mem_task[malloc_current_mem_task % MALLOC_MEM_TASK_COUNT]->code_heap);
|
||||
malloc_current_mem_task++;
|
||||
return res;
|
||||
}
|
||||
|
||||
U0 malloc()
|
||||
{
|
||||
PUSH_SYSV_REGS
|
||||
GET_SYSV_ARGS
|
||||
MAlloc(p0, slon_mem_task->code_heap);
|
||||
@malloc(p0);
|
||||
POP_SYSV_REGS
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user