in reply to
[FCGI.pm] - not threads-safe?
FWIW, FCGI does show a threaded usage, but its the usage the OP is fighting :)
It did start off as fork based but they updated the API
https://metacpan.org/source/FLORA/FCGI-0.74/os_win32.c ... CreateIoCompletionPort...
Tie-in to server architecture. API applications have to share the same architecture as the server: If the Web server is multi-threaded, the application has to be thread-safe. If the Web server has single-threaded processes, multi-threaded applications don't gain any performance advantage. Also, when the server's architecture changes, the API will usually have to change, and applications will have to be adapted or rewritten.
3. Single-threaded and multi-threaded applications
FastCGI gives developers a free choice of whether to develop applications in a single-threaded or multi-threaded style. The FastCGI interface supports multi-threading in two ways:
Applications can accept concurrent Web server connections to provide concurrent requests to multiple application threads.
Applications can accept multiplexed Web server connections, in which concurrent requests are communicated over a single connection to multiple application threads.