Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
alloc: properly allocate memory handler per thread
Right now the memory handler is allocated once, for the first thread that happens to call it. If pthread_getspecific is then called from another thread, the memory handler is not allocated (because pthread_once is only called for *all* threads, not per thread) and jq aborts because it thinks memory allocation failed. What we need to do instead is call pthread_key_create from the initializer, and then allocate a memory handler for every thread when it sees there's none yet. I also removed the atexit stuff, and instead use the destructor function you can pass into pthread_key_create.
- Loading branch information