CivetWeb will spawn and reuse threads to handle requests.
Civetweb is calling my callback in every new thread so I could set it up (register in GC).
On every request, civetweb will call my haxe function (in the worker thread), my haxe function will wait on a lock, pass the lock to MainLoop who has ownership on some internal data, delegate some work to other threadpools, and release the lock on finish. so civetweb will receive the response test, free the memory and mark the thread for reuse.
Some times my application locks up, when I pause it it seems like he last instruction was in futex wait, and the call stack is related to GC, I suspect that I need to use gc_enter_blocking.
When I tried to use it from cpp.vm.Gc.enterGCFreeZone(), I did recive zone mismatch.
I want to do it from cpp using hx::GCEnterBlocking(), where is the defenition of it, which header to need to include in order to use it from CivetWeb code?
Please forgive for using a single thread to process all my requests, I am still cleaning up my logic to make it thread safe, but I suspect that the lockup is GC related, and not related to my code, e.g. it always locks at random lines, not before a lock, or some IO.
Also please advice of any tools that could be used to identify the locking stacks.
After some loggin I was able to identify that new threads are getting stuck right after callling SetTopOfStack
cout << "new thread type " << thread_type << endl;//log is visible even when application stops handling requests.
if (thread_type == 1)
{
int inTop = 0;
hx::SetTopOfStack((int *)&inTop, true);
}
cout << "done initing thread" <<endl;//log not logged