fork() doesn't create processes but threads under Windows. Each thread gets a copy of all the data stored in Perl managed space. The cloning (making a duplicate of the data structures) doesn't affect the private data stored by the XS part of modules. So you only have one copy of that. It also doesn't dup system handles (except I believe sockets and filehandles). This means that
To try to fix the first problem you'll need to use some locking to prevent concurrent access and wrap the function/method calls in that. I'm afraid the performance will suffer and it will be hard to find out whether this is the problem and what to lock.
For the second problem you have to ensure the destroyed objects do not free the memory or the handles. There are several solutions.
It may be hard to do though because the object that needs this treatment may be well hidden inside a different object.
Another problem may be that a module installs an END block that'll free some memory or handles. In that case you'll need to try to "turn it off" by handmodifying some variables. You have to look at the module source of course.
Even if you do all this it is not guaranteed to help. Some modules just do not work well with threads (yet). DBI comes to mind. In that case you might end up changing the code so that only one thread uses that module and provides its functionality to the other threads somehow.
On the other hand I have a script that uses LWP in several threads and it works just fine. I do not create and destroy threads all the time though. I precreate several worker threads and pipe them commands. And it does sometimes crash while exiting (like that it would matter).
Jenda
P.S.: I wrote something on this some time ago, it's available here.
P.P.S.: Nemyslim, ze bys na ty strance "zalozil" anonymous proxy ;-)
In reply to Re: Merlyn Proxy sever fail on win32?
by Jenda
in thread Merlyn Proxy sever fail on win32?
by LiTinOveWeedle
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |