From: "Rajnikant" <[EMAIL PROTECTED]>
> I was trying to use SFTP in multithreaded application. I observed many
> segmentation faults there.
> Following is the code snipet:
>  
> use threads;
> use Net::SFTP;
>  
> my $thrId = 1;
> my $thread = threads->new (\&ftpThreadEntry,$thrId);
> $thrId = 2;
> print("Creating second thread \n");
> my $thread1 = threads->new (\&ftpThreadEntry,$thrId);
>  
> sub ftpThreadEntry()
> {
>    my $ThrId = shift;
>    print (" Thread $ThrId in ftpThreadEntry func\n");
> }
>  
> $thread->join();
> $thread1->join();
> 
> My Observations :
>  
> 1. If we comment out 'use Net::SFTP' then this code runs fine without
> segmentation fault.
> 2. If we uncomment 'use Net::SFTP', it gives segmentation fault :(.
>  
> Can anyone experienced such situation? Is there any dependency in these
> modules or 
> I'm doing it wrong?

The module is most likely not threadsafe ... or uses something that 
is not. Try to load it only in one thread and only after the other 
thread was created.

Keep in mind that you'll have to use either
        require Net::SFTP;
or
        eval "use Net::SFTP";
otherwise the module would still be loaded too soon.

Jenda
===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
        -- Terry Pratchett in Sourcery


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to